Module: Clamp::Option::Declaration

Includes:
Attribute::Declaration
Included in:
Command
Defined in:
lib/clamp/option/declaration.rb

Instance Method Summary collapse

Instance Method Details

#declared_optionsObject



23
24
25
# File 'lib/clamp/option/declaration.rb', line 23

def declared_options
  @declared_options ||= []
end

#find_option(switch) ⇒ Object



19
20
21
# File 'lib/clamp/option/declaration.rb', line 19

def find_option(switch)
  recognised_options.find { |o| o.handles?(switch) }
end

#option(switches, type, description, opts = {}, &block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/clamp/option/declaration.rb', line 11

def option(switches, type, description, opts = {}, &block)
  Option::Definition.new(switches, type, description, opts).tap do |option|
    declared_options << option
    block ||= option.default_conversion_block
    define_accessors_for(option, &block)
  end
end

#recognised_optionsObject



27
28
29
30
# File 'lib/clamp/option/declaration.rb', line 27

def recognised_options
  declare_implicit_options
  effective_options
end