Module: GemRelease::CommandOptions

Defined in:
lib/gem_release/command_options.rb

Instance Method Summary collapse

Instance Method Details

#initialize(*args) ⇒ Object


3
4
5
6
# File 'lib/gem_release/command_options.rb', line 3

def initialize(*args)
  @arguments = ''
  super
end

#option(key, short, description) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gem_release/command_options.rb', line 8

def option(key, short, description)
  default = self.class::DEFAULTS[key]

  if default.is_a?(String)
    long = "--#{key} #{key.to_s.upcase}"
    if default == ''
      default_description = 'not set by default'
    else
      default_description = "defaults to #{default}"
    end
    args = [short, long, String, "#{description} (#{default_description})"]
  else
    long = "--[no-]#{key}"
    args = [short, long, "#{description} (defaults to #{default})"]
  end

  add_option(*args) { |value, options| options[key] = value }
end