Method: Filigree::Configuration::ClassMethods#option

Defined in:
lib/filigree/configuration.rb

#option(long, short = nil, conversions: nil, &block) ⇒ void

This method returns an undefined value.

Define a new option.

Parameters:

  • long (String)

    Long option name

  • short (String) (defaults to: nil)

    Short option name

  • conversions (Array<Symbol>) (defaults to: nil)

    List of methods used to convert string arguments

  • block (Proc)

    Block used when the option is encountered



286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/filigree/configuration.rb', line 286

def option(long, short = nil, conversions: nil, &block)
  long  = long.to_s.gsub('-', '_')
  short = short.to_s if short

  add_option Option.new(long, short, @help_string, @next_default,
                      conversions.nil? ? block : conversions)

  @required << long.to_sym if @next_required

  # Reset state between option declarations.
  @help_string   = ''
  @next_default  = nil
  @next_required = false
end