Method: Puppet::Application.option
- Defined in:
- lib/puppet/application.rb
.option(*options, &block) ⇒ Object
used to declare code that handle an option
180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/puppet/application.rb', line 180 def option(*, &block) long = .find { |opt| opt =~ /^--/ }.gsub(/^--(?:\[no-\])?([^ =]+).*$/, '\1').tr('-', '_') fname = "handle_#{long}".intern if block_given? define_method(fname, &block) else define_method(fname) do |value| self.[long.to_s.to_sym] = value end end option_parser_commands << [, fname] end |