The GetOpt class provides an easy way to process POSIX-style command-line options in Qore scripts/programs.
More...
|
| | 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.
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.
- Parameters
-
| 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 |
- Returns
- A hash keyed by option names (as given in the hash to the GetOpt constructor), where each key's value is the value of the argument passed in the list argument. The hash key
"_ERRORS_" will contain any errors.
- Example:
1 hash o = getopt.parse(\ARGV);
2 if (exists o.
"_ERRORS_") {
3 foreach string err
in (o.
"_ERRORS_")
4 stderr.printf(
"%s\n", err);
- See Also
- GetOpt::parse2() for a similar method that throws an exception instead of putting error information in the
"_ERRORS_" key of the hash value returned