diff --git a/lib/github_changelog_generator.rb b/lib/github_changelog_generator.rb index 4ff4a1b..17164dd 100755 --- a/lib/github_changelog_generator.rb +++ b/lib/github_changelog_generator.rb @@ -20,13 +20,7 @@ module GitHubChangelogGenerator @options = Parser.parse_options - if options[:verbose] - puts 'Input options:' - pp options - puts '' - end - - github_token + fetch_github_token github_options = {per_page: PER_PAGE_NUMBER} github_options[:oauth_token] = @github_token unless @github_token.nil? @@ -113,11 +107,6 @@ module GitHubChangelogGenerator puts JSON.pretty_generate(json) end - def exec_command(cmd) - exec_cmd = "cd #{$project_path} and #{cmd}" - %x[#{exec_cmd}] - end - def fetch_merged_at_pull_requests if @options[:verbose] print "Fetching merged dates...\r" @@ -314,12 +303,8 @@ module GitHubChangelogGenerator tags end - def github_token - if @options[:token] - return @github_token ||= @options[:token] - end - - env_var = ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil + def fetch_github_token + env_var = @options[:token] ? @options[:token] : (ENV.fetch 'CHANGELOG_GITHUB_TOKEN', nil) unless env_var puts "Warning: No token provided (-t option) and variable $CHANGELOG_GITHUB_TOKEN was not found.".yellow diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 3c8b5cd..fd0723c 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -6,8 +6,8 @@ require_relative 'version' module GitHubChangelogGenerator class Parser def self.parse_options - # :include_labels => %w(bug enhancement), - hash = { + + options = { :tag1 => nil, :tag2 => nil, :format => '%Y-%m-%d', @@ -28,7 +28,6 @@ module GitHubChangelogGenerator :unreleased => true, :unreleased_label => 'Unreleased' } - options = hash parser = OptionParser.new { |opts| opts.banner = 'Usage: github_changelog_generator [options]' @@ -149,6 +148,12 @@ module GitHubChangelogGenerator options[:tag2] = ARGV[1] end + if options[:verbose] + puts 'Performing task with options:' + pp options + puts '' + end + options end end