diff --git a/lib/github_changelog_generator/parser.rb b/lib/github_changelog_generator/parser.rb index 5001ad6..502b6d6 100644 --- a/lib/github_changelog_generator/parser.rb +++ b/lib/github_changelog_generator/parser.rb @@ -9,20 +9,14 @@ module GitHubChangelogGenerator def self.parse_options options = get_default_options - parser_file = ParserFile.new options - parser_file.parse! + ParserFile.new(options).parse! parser = setup_parser(options) parser.parse! - if options[:user].nil? || options[:project].nil? - detect_user_and_project(options, ARGV[0], ARGV[1]) - end + user_and_project_from_git(options) - if !options[:user] || !options[:project] - puts parser.banner - exit - end + abort(parser.banner) unless options[:user] && options[:project] print_options(options) @@ -198,17 +192,23 @@ module GitHubChangelogGenerator options end + def self.user_and_project_from_git + if options[:user].nil? || options[:project].nil? + detect_user_and_project(options, ARGV[0], ARGV[1]) + end + end + # Detects user and project from git def self.detect_user_and_project(options, arg0 = nil, arg1 = nil) options[:user], options[:project] = user_project_from_option(arg0, arg1, options[:github_site]) - if !options[:user] || !options[:project] - if ENV["RUBYLIB"] =~ /ruby-debug-ide/ - options[:user] = "skywinder" - options[:project] = "changelog_test" - else - remote = `git config --get remote.#{options[:git_remote]}.url` - options[:user], options[:project] = user_project_from_remote(remote) - end + return if options[:user] && options[:project] + + if ENV["RUBYLIB"] =~ /ruby-debug-ide/ + options[:user] = "skywinder" + options[:project] = "changelog_test" + else + remote = `git config --get remote.#{options[:git_remote]}.url` + options[:user], options[:project] = user_project_from_remote(remote) end end