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



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/filigree/configuration.rb', line 266

def option(long, short = nil, conversions: nil, &block)

	attr_accessor long.to_sym

	long  = long.to_s
	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