Class: Boson::OptionCommand
- Inherits:
-
Object
- Object
- Boson::OptionCommand
- Extended by:
- ClassRender
- Includes:
- Render
- Defined in:
- lib/boson/more_scientist.rb,
lib/boson/science.rb
Overview
Any command with options comes with basic global options. For example ‘-hv’ on an option command prints a help summarizing global and local options. Another basic global option is –pretend. This option displays what global options have been parsed and the actual arguments to be passed to a command if executed. For example:
# Define this command in a library
options :level=>:numeric, :verbose=>:boolean
def foo(*args)
args
end
irb>> foo 'testin -p -l=1'
Arguments: ["testin", {:level=>1}]
Global options: {:pretend=>true}
If a global option conflicts with a local option, the local option takes precedence. You can get around this by passing global options after a ‘-’. For example, if the global option -h (–help) conflicts with a local -h (–force):
foo 'arg1 -v -f - -f=f1,f2'
# is the same as
foo 'arg1 -v --fields=f1,f2 -f'
Defined Under Namespace
Modules: ClassRender, Render
Constant Summary collapse
- PIPE_OPTIONS =
{ :sort=>{:type=>:string, :desc=>"Sort by given field"}, :reverse_sort=>{:type=>:boolean, :desc=>"Reverse a given sort"}, :query=>{:type=>:hash, :desc=>"Queries fields given field:search pairs"}, :pipes=>{:alias=>'P', :type=>:array, :desc=>"Pipe to commands sequentially"} }
- RENDER_OPTIONS =
:nodoc:
{ :fields=>{:type=>:array, :desc=>"Displays fields in the order given"}, :class=>{:type=>:string, :desc=>"Hirb helper class which renders"}, :max_width=>{:type=>:numeric, :desc=>"Max width of a table"}, :vertical=>{:type=>:boolean, :desc=>"Display a vertical table"}, }
Method Summary
Methods included from ClassRender
default_options, default_pipe_options, default_render_options, delete_non_render_options
Methods included from Render
#all_global_options, #option_parser, #set_global_option_defaults