Qore Programming Language Reference Manual
0.9.2
|
The GetOpt class provides an easy way to process POSIX-style command-line options in Qore scripts/programs. More...
Public Member Methods | |
constructor (hash options) | |
Creates the GetOpt object and sets the option hash with the single required argument. More... | |
copy () | |
Throws an exception; objects of this class cannot be copied. More... | |
hash | parse (reference< list< string >> pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash | parse (softlist pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash | parse2 (reference< list< string >> pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash | parse2 (softlist pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash | parse3 (reference< list< string >> pgm_args) |
Parses the parameter list according to the option hash passed to the constructor and displays an explanatory error message on stderr and exits the program if an error occurs. More... | |
hash | parse3 (softlist pgm_args) |
Parses the parameter list according to the option hash passed to the constructor and displays an explanatory error message on stderr and exits the program if an error occurs. More... | |
The GetOpt class provides an easy way to process POSIX-style command-line options in Qore scripts/programs.
Qore::GetOpt::constructor | ( | hash | options | ) |
Creates the GetOpt object and sets the option hash with the single required argument.
options | Each key defines the key value for the return hash if any arguments are given corresponding to the string value of the key; The string value of each hash key follows the following pattern: opts [(=|:) type[ modifier]] Where the meaning of the above placeholders in italics is:
|
GETOPT-PARAMETER-ERROR | option key value is not a string; "_ERRORS_" used as option key |
GETOPT-OPTION-ERROR | list option specified as optional; empty option key value string; multiple long options given for key; duplicate options given; invalid attributes for option; unknown modifier given for option |
Qore::GetOpt::copy | ( | ) |
Throws an exception; objects of this class cannot be copied.
GETOPT-COPY-ERROR | copying GetOpt objects is not supported |
Parses the parameter list according to the option hash passed to the constructor.
All arguments parsed will be removed from the list reference passed as the sol argument, leaving only unparsed arguments (for example, file names).
If any errors are encountered, the return value hash will have a key "_ERRORS_"
giving a list of error messages pertaining to the options parsed.
pgm_args | The reference should point to a list of arguments to process (normally ARGV ); any argument accepted by the object will be removed from the list |
"_ERRORS_"
will contain any errors."_ERRORS_"
key of the hash value returned hash Qore::GetOpt::parse | ( | softlist | pgm_args | ) |
Parses the parameter list according to the option hash passed to the constructor.
If any errors are encountered, the return value hash will have a key "_ERRORS_"
giving a list of error messages pertaining to the options parsed.
pgm_args | A list of arguments to process |
"_ERRORS_"
will contain any errors."_ERRORS_"
key of the hash value returned Parses the parameter list according to the option hash passed to the constructor.
If any errors are encountered, an appropriate exception will be thrown.
pgm_args | The reference should point to a list of arguments to process (normally ARGV ); any argument accepted by the object will be removed from the list |
GETOPT-ERROR | error parsing arguments |
"_ERRORS_"
key of the hash value returned instead of throwing an exception hash Qore::GetOpt::parse2 | ( | softlist | pgm_args | ) |
Parses the parameter list according to the option hash passed to the constructor.
If any errors are encountered, an appropriate exception will be thrown.
pgm_args | A list of arguments to process |
GETOPT-ERROR | error parsing arguments |
"_ERRORS_"
key of the hash value returned instead of throwing an exception Parses the parameter list according to the option hash passed to the constructor and displays an explanatory error message on stderr and exits the program if an error occurs.
pgm_args | The reference should point to a list of arguments to process (normally ARGV ); any argument accepted by the object will be removed from the list |
"_ERRORS_"
key of the hash value returnedhash Qore::GetOpt::parse3 | ( | softlist | pgm_args | ) |
Parses the parameter list according to the option hash passed to the constructor and displays an explanatory error message on stderr and exits the program if an error occurs.
pgm_args | A list of arguments to process |
GETOPT-ERROR | error parsing arguments |
"_ERRORS_"
key of the hash value returned