Module: Cli

Defined in:
lib/cli.rb

Class Method Summary collapse

Class Method Details

.options!(args = ARGV) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cli.rb', line 6

def self.options!(args = ARGV)

  options = {}

  OptionParser.new do |opts|
    opts.banner = "    Extracts from TargetProcess the cumulative flow for a specific team, and prints it in CSV format\n\n    Usage:   \#{$PROGRAM_NAME} [options]\n\n    STRING\n\n    opts.on(\"-t\", \"--team TEAM_ABBREVIATION\", \"(required) select a team to filter the data\") do |team|\n      options[:team] = team\n    end\n\n    opts.on(\"-p\", \"--project PROJ_ABBREVIATION\", \"(required) select a project to filter the data\") do |project|\n      options[:project] = project\n    end\n\n    opts.on(\"-u\", \"--username USERNAME\", \"(required) username to log on TargetProcess\") do |username|\n      options[:username] = username\n    end\n\n    opts.on(\"-b\", \"--base-uri URI\", \"(required) URI of TargetProcess\") do |uri|\n      options[:base_uri] = uri\n    end\n\n    opts.on(\"--states STATES\", \"included states, separated by commas\") do |states|\n      options[:states] = states.split(',').map(&:chomp)\n    end\n\n    options[:day] = \"tuesday\"\n    opts.on(\"-d\", \"--day DAY\", %w{monday tuesday wednesday thursday friday saturday sunday},\n            \"day of week used as iteration start (defaults to tuesday)\") do |day|\n      options[:day] = day\n    end\n\n    options[:verify] = true\n    opts.on(\"--[no-]verify\", \"verify ssl certificates\") do |verify|\n      options[:verify] = verify\n    end\n\n  end.parse!(args)\n\n  unless options[:username] then\n    options[:username] = get_input(\"Username: \")\n  end\n\n  options[:password] = get_input(\"Password: \", echo: false)\n\n  options\nend\n".gsub(/^ +/, '')