Class Args |
The Args class accepts a list of strings corresponding to the program parameter list, separates options (parameters starting with 1 or more hyphens ["-"]) from arguments (parameters) that don't start with a hyphen) and provides convenient and efficient separate handling of those options and arguments. Options may have values as in --cmd=write. If an option is duplicated, the values (if any) are kept in order. Arguments are also kept in order.
The class may also be given a set of valid option names (without the leading hyphens. If given such a set, then any options that are not in the set are flagged to standard error and program execution is halted. The class can also be given a procedure to call prior to program termination when bad options are found. Usually, this is used to display a help message.
Details |
Constructor |
Args(params, validOptions, helpMesg)
params | List of parametes
|
validOptions | Option set of valid option names
|
helpMesg | Optional help message procedure to be
called if any invalid options are found
|
Accept a list of arguments and process for efficient handling
Methods: |
arguments |
Generate the arguments (with options stripped out).
option | name of option |
defValue | default value to use if option does not exist
Defaults to &null |
all values given to option |
Generate the value[s] of an option.
the names of all the options in alphabetic order |
Generate the names of all options.
list of arguments |
Produce the list of arguments (with options stripped out).
option | name of option |
defValue | default value to use if option exists, but
has no value. Defaults to &null |
first value given to option |
if this option doesn't exist |
Produce the value of an option.
option | name of option |
defValue | default value to use if option does not exist
Defaults to &null |
first value given to option |
Produce the value of an option.
option | name of option |
defValue | default value to use if option does not exist
Defaults to &null |
all values given to option as a list |
Produce the value[s] of an option.
Fields: |