Method: OptparsePlus::Main#options

Defined in:
lib/optparse_plus/main.rb

#optionsObject

Returns a Hash that you can use to store or retrieve options parsed from the command line. When you put values in here, if you do so before you’ve declared your command-line interface via #on, the value will be used in the docstring to indicate it is the default. You can use either a String or a Symbol and, after #go! is called and the command-line is parsed, the values will be available as both a String and a Symbol.

Example

main do
  puts options[:foo] # put the value of --foo that the user provided
end

options[:foo] = "bar" # set "bar" as the default value for --foo, which
                      # will cause us to include "(default: bar)" in the
                      # docstring

on("--foo FOO","Sets the foo")
go!


276
277
278
# File 'lib/optparse_plus/main.rb', line 276

def options
  @options ||= {}
end