Module: SimpleScripting::Argv
Defined Under Namespace
Classes: ExitError
Instance Method Summary collapse
Instance Method Details
#decode(*params_definition, arguments: ARGV, long_help: nil, output: $stdout) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/simple_scripting/argv.rb', line 11 def decode(*params_definition, arguments: ARGV, long_help: nil, output: $stdout) # WATCH OUT! @long_help can also be set in :decode_command!. See issue #17. # @long_help = long_help @output = output if params_definition.first.is_a?(Hash) decode_command!(params_definition, arguments) else decode_arguments!(params_definition, arguments) end rescue ExitError # return nil, to be used with the 'decode(...) || exit' pattern ensure # Clean up the instance variables. # # There is a balance to strike between instance variables, and local variables # passed around. One of the options, which is this case, is to set and instance # variables only these two, which are constant. @long_help = nil @output = nil end |