dist_tools/
mg_options__define.pro
includes main-level programAn object to facilitate parsing of command line options.
Execute this program with something like:
idl -IDL_QUIET 1 -quiet -e ".run mg_options__define" -args --verbose--name=Mike
or:
idl -IDL_QUIET 1 -quiet -e ".run mg_options__define" -args --help
Class description for mg_opt
Properties
- help init
- short_name get set
- boolean init
- key_column_width get
- help_header get
- default init
- long_name init
Fields
- present 0B
true if value has been set
- help ''
text to print for the option if help is asked for
- boolean 0B
true if option is a boolean type option
- value ''
value of the option
- default ''
default value if value is not present
- shortName ''
single character abbreviation for the option
- longName ''
long name of the option
Class description for mg_options
Properties
- app_name init
- version init
Fields
- longOptions obj_new()
hash table of options keyed on long name of option
- APPNAME ''
- VERSION ''
- shortOptions obj_new()
hash table of options keyed on short name of option, if present
- PARAMS obj_new()
- NPARAMSACCEPTED [0L, 0L]
Other file information
- Requires:
IDL 6.2
- Todo:
handle the following cases: -nNAME, -n NAME, --name NAME display other info afterward usage: and options: in the help
- Uses:
Routines
mg_opt::setProperty, short_name=short_name
Set properties.
mg_opt::getProperty, short_name=short_name, key_column_width=key_column_width, help_header=help_header
Get properties.
result = mg_opt::isPresent()
Returns whether the option has had a value set i.e.
result = mg_opt::getHelp()
Returns the help text for the option.
result = mg_opt::getValue( [/present])
Get value of the option.
mg_opt::setValue [, value]
Set the value of the option.
result = mg_opt::init(long_name=string [, /boolean] [, help=string] [, default=string])
Create an option.
mg_opt__define
Define instance variables.
result = mg_options::get(optname [, /params] [, n_params=long] [, /present])
Get value of option.
mg_options::displayHelp
Display the help for the defined options.
mg_options::displayVersion
Print version information.
mg_options::parseArgs [, args] [, error_message=string]
Parse arguments.
mg_options::addOption, longForm [, shortForm] [, help=string] [, default=string] [, /boolean]
Add the definition of an option to the parser.
mg_options::addParams, nparamsRange
Add a range of positional parameters.
mg_options::cleanup
Free resources.
result = mg_options::init( [app_name=string] [, version=string])
Create option parsing object.
mg_options__define
Define instance variables.
Routine details
topmg_opt::setProperty
mg_opt::setProperty, short_name=short_name
Set properties.
Keywords
- short_name
topmg_opt::getProperty
mg_opt::getProperty, short_name=short_name, key_column_width=key_column_width, help_header=help_header
Get properties.
Keywords
- short_name
- key_column_width
- help_header
topmg_opt::isPresent
result = mg_opt::isPresent()
Returns whether the option has had a value set i.e. it is present on the current command line.
Return value
byte
topmg_opt::getHelp
result = mg_opt::getHelp()
Returns the help text for the option.
Return value
string
topmg_opt::getValue
result = mg_opt::getValue( [/present])
Get value of the option.
Return value
string (normally) or byte (if boolean)
Keywords
- present out optional type=boolean
set to a named variable to determine if the option is present
topmg_opt::setValue
mg_opt::setValue [, value]
Set the value of the option.
Parameters
- value in optional type=string
value of the option
topmg_opt::init
result = mg_opt::init(long_name=string [, /boolean] [, help=string] [, default=string])
Create an option.
Return value
1 for success, 0 for failure
Keywords
- long_name in required type=string
long name of the option
- boolean in optional type=boolean
set to indicate the option is boolean i.e. it does not take a value, being present "sets" it
- help in optional type=string default=''
help text to display for the option
- default in optional type=string default=''
default value of the option
topmg_options::get
result = mg_options::get(optname [, /params] [, n_params=long] [, /present])
Get value of option.
Return value
string
Parameters
- optname in required type=string
long name of option
Keywords
- params in optional type=boolean
set to return parameters
- n_params out optional type=long
number of parameters returned, only used if PARAMS is set
- present out optional type=boolean
set to a named variable to determine if the option was present
topmg_options::parseArgs
mg_options::parseArgs [, args] [, error_message=string]
Parse arguments.
Parameters
- args in optional type=strarr default=command_line_args()
string array of arguments
Keywords
- error_message out optional type=string
set to a named variable to receive any error message generated from parsing the parameters
topmg_options::addOption
mg_options::addOption, longForm [, shortForm] [, help=string] [, default=string] [, /boolean]
Add the definition of an option to the parser.
Parameters
- longForm in required type=string
long name of the option, used with two dashes i.e. --help
- shortForm in optional type=string
single character name of an option, used with a single dash i.e. -h
Keywords
- help in optional type=string
help text for the option
- default in optional type=string
default value
- boolean in optional type=boolean
set to indicate the option is a boolean switch
topmg_options::addParams
mg_options::addParams, nparamsRange
Add a range of positional parameters.
Parameters
- nparamsRange in required type=lonarr(2)
valid range for number of positional parameters, use -1 for the max value to allow an unlimited number of parameters
File attributes
Modification date: | Thu Apr 23 21:50:54 2009 |
Lines: | 531 |
Docformat: | rst rst |