Module: Miniparse
- Defined in:
- lib/miniparse/parser.rb,
lib/miniparse/version.rb,
lib/miniparse/command.rb,
lib/miniparse/control.rb,
lib/miniparse/internals.rb,
lib/miniparse/constants.rb,
lib/miniparse/commander.rb,
lib/miniparse/option_broker.rb
Defined Under Namespace
Classes: Parser
Constant Summary
- VERSION =
semantic versioning MAJOR.MINOR.PATCH [pre]release
"0.5.0.pre"
- ERR_HELP_REQ =
1
- ERR_ARGUMENT =
2
- DEFAULT_CONTROLS =
{ # gives an error if there is an unrecognized option either short or long # (if not then passes them as arguments) raise_on_unrecognized: true, # intercepts .parse ArgumentError (i.e. the commandline user introduced # wrong or invalid options) and exits with a helpful msg rescue_argument_error: true, # gives usage help and exits if commandline is empty # useful if your app always needs args or options to work help_cmdline_empty: false, # raises an ArgumentError if there are global args # (after parsing options and commands) # useful if you don't expect any args raise_global_args: false, # formats help output with the width_... controls formatted_help: true, width_display: 79, width_indent: 3, width_left: 18, # use a detailed options help usage msg or a generic one detailed_usage: true, # uses --no-... options for all options # useful if you want all your options to be negatable by default autonegatable: false, # uses short options (besides long ones) for all options # useful if you want all your options to be shortable by default autoshortable: false, # TODO: consider adding following control # admits -h besides --help in help predefined option # shortable_help: false, }
Class Method Summary (collapse)
-
+ (boolean) control(key)
The current value of specified control.
- + (void) reset_default_controls
-
+ (void) set_control(opts = {})
sets the control values specified in the hash, modern abbreviated notation can be used like e.g.
Class Method Details
+ (boolean) control(key)
Returns the current value of specified control
15 16 17 |
# File 'lib/miniparse/control.rb', line 15 def self.control(key) @behaviour_controls.fetch(key) end |
+ (void) reset_default_controls
This method returns an undefined value.
4 5 6 7 |
# File 'lib/miniparse/control.rb', line 4 def self.reset_default_controls @behaviour_controls = {} @behaviour_controls.merge! DEFAULT_CONTROLS end |
+ (void) set_control(opts = {})
This method returns an undefined value.
sets the control values specified in the hash, modern abbreviated notation can be used like e.g.
set_control(autoshortable: true)
set_control(autoshortable: true, autonegatable: true)
27 28 29 30 |
# File 'lib/miniparse/control.rb', line 27 def self.set_control(opts = {}) opts.keys.each { |key| @behaviour_controls.fetch key } @behaviour_controls.merge! opts end |