Module: RakeCommander::Options::Result

Defined in:
lib/rake-commander/options/result.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#options(argv = ARGV, &block) ⇒ Hash

Launches the options parsing of this class.

Returns:

  • (Hash)

    keyed by short.



96
97
98
99
100
101
# File 'lib/rake-commander/options/result.rb', line 96

def options(argv = ARGV, &block)
  return @options if instance_variable_defined?(:@options)
  @options = {}
  self.class.parse_options(argv, results: @options, leftovers: options_leftovers, &block)
  @options
end

#options_leftoversObject

Note:

an unknown option (i.e. -f something, --foo something) would trigger an invalid option error. This means that the leftovers can only refer to arguments not paired to options that receive parameters (i.e. --no-foo something).

The options part (so after --) that was NOT processed by the OptionParser. They are therefore unknown parameters.



108
109
110
# File 'lib/rake-commander/options/result.rb', line 108

def options_leftovers
  @options_leftovers ||= []
end