lib/pronto/cli.rb in pronto-0.0.2 vs lib/pronto/cli.rb in pronto-0.1.0

- old
+ new

@@ -5,38 +5,49 @@ require 'pronto' require 'pronto/version' desc 'exec', 'Run Pronto' - method_option :commit1, + method_option :commit, type: :string, default: nil, - aliases: '-f', - banner: 'First commit for the diff, defaults to current HEAD' + aliases: '-c', + banner: 'Commit for the diff, defaults to master' - method_option :commit2, - type: :string, - default: nil, - aliases: '-s', - banner: 'Second commit for the diff, defaults to master' - method_option :runner, type: :array, default: [], aliases: '-r', banner: 'Run only the passed runners' + method_option :formatter, + type: :string, + default: nil, + aliases: '-f', + banner: "Formatter, defaults to text. Available: #{::Pronto::Formatter.names.join(', ')}" + + method_option :access_token, + type: :string, + default: nil, + aliases: '-t', + banner: 'Github access token, used for github formatter' + def exec gem_names = options[:runner].any? ? options[:runner] : ::Pronto.gem_names gem_names.each do |gem_name| require "pronto/#{gem_name}" end - puts ::Pronto.run(options[:commit1], options[:commit2]) + + formatter = ::Pronto::Formatter.get(options[:formatter]) + if formatter.is_a? ::Pronto::Formatter::GithubFormatter + access_token = options[:access_token] + formatter.client = Octokit::Client.new(access_token: access_token) + end + + puts ::Pronto.run(options[:commit], '.', formatter) rescue Rugged::RepositoryError puts '"pronto" should be run from a git repository' - rescue => e - puts e.message end desc 'list', 'Lists pronto runners that are available to be used' def list