Skip to content

Add option (-o --output) to specify name of the output file. #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,34 @@ Github Changelog Generator
This script automatically generate change-log from your tags and merged pull-requests.

## Installation:
`gem install github_changelog_generator`
gem install github_changelog_generator

## Usage:
## Usage

### Example usage:
`github_changelog_generator -u github-username -p github-project`
github_changelog_generator -u github-username -p github-project

In output you will get `[your_project]_changelog.md` file with *pretty Markdown-formatted* changelogs in your current directory.
In output you will get `CHANGELOG.md` file with *pretty Markdown-formatted* changelogs in your current directory.

### Params:
github_changelog_generator -u user_name -p project_name [-t 16-digit-GitHubToken] [options]
-u, --user [USER] your username on GitHub
-p, --project [PROJECT] name of project on GitHub
-t, --token [TOKEN] To make more than 50 requests this app required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications
See `github_changelog_generator --help` for detailed usage.

Usage: changelog_generator --user username --project project_name [options]
-u, --user [USER] Username of the owner of target GitHub repo (required)
-p, --project [PROJECT] Name of project on GitHub (required)
-t, --token [TOKEN] To make more than 50 requests this script required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications
-h, --help Displays Help
-v, --[no-]verbose Run verbosely
-l, --last-changes generate log between last 2 tags
-f, --date-format [FORMAT] date format. default is %d/%m/%y

-l, --last-changes Generate log between only last 2 tags
-f, --date-format [FORMAT] Date format. Default is %d/%m/%y
-o, --output [FORMAT] Output file. Default is CHANGELOG.md

## Real examples:
### [This changelog](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md) was generated by
`github_changelog_generator -u skywinder -p ActionSheetPicker-3.0`: [ActionSheetPicker-3.0/CHANGELOG.md](https://github.com/skywinder/ActionSheetPicker-3.0/blob/master/CHANGELOG.md)

## FAQ
Since GitHub allow to make only 50 requests without authentication it's recommended to run this scrip with key `-t [your 16 digit token]` that you can easily **[generate here](https://github.com/settings/applications)**.
Since GitHub allow to make only 50 requests without authentication it's recommended to run this scrip with key `-t [your 16 digit token]` that you can easily **[generate it here](https://github.com/settings/applications)**.

So, if you got error like this:
>! /Library/Ruby/Gems/2.0.0/gems/github_api-0.12.2/lib/github_api/response/raise_error.rb:14:in `on_complete': GET https://api.github.com/repos/skywinder/ActionSheetPicker-3.0/git/commits/89678f7d7f66873c858e6cb07bf697192aca6768: 403 API rate limit exceeded for 195.88.177.9. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.) (Github::Error::Forbidden)
Expand Down
7 changes: 3 additions & 4 deletions github_changelog_generator.gemspec
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Gem::Specification.new do |s|
s.name = "github_changelog_generator"
s.version = "0.0.1"
s.version = "0.0.2"
s.default_executable = "github_changelog_generator"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.required_ruby_version = '>= 1.9.3'
s.authors = ["Petr Korolev"]
s.date = %q{2014-10-10}
s.description = %q{Script, that automatically generate change-log from your tags and pull-requests}
Expand All @@ -14,8 +14,7 @@ Gem::Specification.new do |s|
s.rubygems_version = %q{1.6.2}
s.summary = %q{Script, that automatically generate change-log from your tags and pull-requests.}
s.license = "MIT"

s.add_runtime_dependency(%q<httparty>, ["~> 0.6"])
s.add_runtime_dependency(%q<httparty>, ["~> 0.13"])
s.add_runtime_dependency(%q<github_api>, ["~> 0.12"])

s.executables = %w(github_changelog_generator)
Expand Down
4 changes: 3 additions & 1 deletion lib/github_changelog_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def compund_changelog
puts log
end

output_filename = "#{@options[:project]}_changelog.md"
log += "\n\n*This file was generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*"

output_filename = "#{@options[:output]}"
File.open(output_filename, 'w') { |file| file.write(log) }

puts "Done! Generated log placed in #{output_filename}"
Expand Down
17 changes: 10 additions & 7 deletions lib/github_changelog_generator/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

class Parser
def self.parse_options
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y'}
options = {:tag1 => nil, :tag2 => nil, :format => '%d/%m/%y', :output => 'CHANGELOG.md'}

parser = OptionParser.new { |opts|
opts.banner = 'Usage: changelog_generator -u user_name -p project_name [-t 16-digit-GitHubToken] [options]'
opts.on('-u', '--user [USER]', 'your username on GitHub') do |last|
opts.banner = 'Usage: changelog_generator --user username --project project_name [options]'
opts.on('-u', '--user [USER]', 'Username of the owner of target GitHub repo (required)') do |last|
options[:user] = last
end
opts.on('-p', '--project [PROJECT]', 'name of project on GitHub') do |last|
opts.on('-p', '--project [PROJECT]', 'Name of project on GitHub (required)') do |last|
options[:project] = last
end
opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests this app required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications') do |last|
opts.on('-t', '--token [TOKEN]', 'To make more than 50 requests this script required your OAuth token for GitHub. You can generate it on https://github.com/settings/applications') do |last|
options[:token] = last
end
opts.on('-h', '--help', 'Displays Help') do
Expand All @@ -23,12 +23,15 @@ def self.parse_options
opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
options[:verbose] = v
end
opts.on('-l', '--last-changes', 'generate log between last 2 tags') do |last|
opts.on('-l', '--last-changes', 'Generate log between only last 2 tags') do |last|
options[:last] = last
end
opts.on('-f', '--date-format [FORMAT]', 'date format. default is %d/%m/%y') do |last|
opts.on('-f', '--date-format [FORMAT]', 'Date format. Default is %d/%m/%y') do |last|
options[:format] = last
end
opts.on('-o', '--output [FORMAT]', 'Output file. Default is CHANGELOG.md') do |last|
options[:output] = last
end
}

parser.parse!
Expand Down