Class: MergetrainCheck::ArgsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/mergetrain_check/args_parser.rb

Instance Method Summary collapse

Instance Method Details

#parse(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mergetrain_check/args_parser.rb', line 5

def parse(args)
  options = {}
  parser = OptionParser.new do |opts|
    opts.banner = "Usage: mergetrain_check [options] [PROJECT-ID]\n" +
      "       PROJECT-ID: The project ID to fetch the merge train list from. If none specified, it will try to use the last one used.\n\n"
    opts.on("-t", "--token GITLAB-PERSONAL-TOKEN", "Gitlab API token (go to https://[gitlab_host]/profile/personal_access_tokens) to generate one.") do |t|
      options[:token] = t
    end
    opts.on("-n", "--host GITLAB-HOSTNAME", "Specify the Gitlab installation host (in case it's not gitlab.com)") do |host|
      options[:host] = host
    end
    opts.on("-h", "--help", "Prints this help") do
      puts opts
      return nil
    end
  end
  parser.parse!(args)
  options[:project_id] = args[0] if args.length > 0
  options

end