Class: Idonethis::UseCases::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/idonethis/use_cases/options.rb

Class Method Summary collapse

Class Method Details

.parse(argv = {}) ⇒ Object



4
5
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
# File 'lib/idonethis/use_cases/options.rb', line 4

def parse(argv={})
  args = {}

  require 'optparse'
  
  OptionParser.new do |opts|
    opts.banner = "Usage: command [options]"

    opts.on("-v", "--verbose", "Run verbosely") do |v|
      args[:verbose] = v
    end

    opts.on("-m MESSAGE", "Message") do |m|
      args[:message] = m
    end

    opts.on("-d", "Dry run") do |_|
      args[:dry_run] = true
    end
    
    opts.on("-t TEAM", "--team TEAM" "Run against this team") do |team_name|
      args[:team] = team_name
    end

    opts.on("-s WHEN", "--since WHEN" "Show git commits since when") do |value|
      args[:since] = value
    end

    opts.on("-d DATE", "--date DATE" "Set done date, defaults to now") do |value|
      args[:date] = value
    end
  end.parse!(argv)
  
  args
end