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.



100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rake-commander/options/result.rb', line 100

def options(argv = ARGV, &block) # rubocop:disable Naming/BlockForwarding
  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.



119
120
121
# File 'lib/rake-commander/options/result.rb', line 119

def options_leftovers
  @options_leftovers ||= []
end