Module: CodeReviewLeaderboard::ArgumentParser

Extended by:
ArgumentParser
Included in:
ArgumentParser
Defined in:
lib/code_review_leaderboard/argument_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse!(args: ARGV) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/code_review_leaderboard/argument_parser.rb', line 7

def parse!(args: ARGV)
  {}.tap do |options|
    OptionParser.new do |opts|
      opts.banner = "Usage: leaderboard [options]"

      opts.on("-t", "--access-token ACCESS_TOKEN", "Specify the access token") { |token| options[:access_token] = token }
      opts.on("-r", "--repo", "--repository repository,repository", Array, "Specify the repository") { |repositories| options[:repositories] = repositories }
      opts.on("-o", "--org", "--organization organization", "Specify the organization") { |organization| options[:organization] = organization }
      opts.on("-v", "--verbose", "Run verbosely") { options[:log_level] = :debug }

      opts.on("-h", "--help", "Show this message") do
        puts opts
        exit
      end
    end.parse!(args)
  end
end