Qore Programming Language Reference Manual 1.18.1
|
The GetOpt class provides an easy way to process POSIX-style command-line options in Qore scripts/programs. More...
#include <QC_GetOpt.dox.h>
Public Member Methods | |
constructor (hash< auto > 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< auto > | parse (reference< list< string > > pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash< auto > | parse (softlist< auto > pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash< auto > | parse2 (reference< list< string > > pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash< auto > | parse2 (softlist< auto > pgm_args) |
Parses the parameter list according to the option hash passed to the constructor. More... | |
hash< auto > | 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< auto > | parse3 (softlist< auto > 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... | |
Static Public Member Methods | |
static hash< auto > | parse (hash< auto > opts, reference< list< string > > pgm_args) |
Parses the given options and returns a hash of the parsed options. More... | |
static hash< auto > | parseEx (hash< auto > opts, reference< list< string > > pgm_args) |
Parses the given options and returns a hash of the parsed options and throws and exception if there are any errors. More... | |
static hash< auto > | parseExit (hash< auto > opts, reference< list< string > > pgm_args) |
Parses the given options and returns a hash of the parsed options; prints out an error message and exits the program if there are any errors. More... | |
The GetOpt class provides an easy way to process POSIX-style command-line options in Qore scripts/programs.
Qore::GetOpt::constructor | ( | hash< auto > | 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 |
|
static |
Parses the given options and returns a hash of the parsed options.
opts | a hash where 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:
|
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.All arguments parsed will be removed from pgm_args, 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.
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 sole 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< auto > Qore::GetOpt::parse | ( | softlist< auto > | 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< auto > Qore::GetOpt::parse2 | ( | softlist< auto > | 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< auto > Qore::GetOpt::parse3 | ( | softlist< auto > | 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
|
static |
Parses the given options and returns a hash of the parsed options and throws and exception if there are any errors.
opts | a hash where 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:
|
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 |
All arguments parsed will be removed from pgm_args, leaving only unparsed arguments (for example, file names).
If any errors are encountered, a GETOPT-ERROR
exception is thrown.
GETOPT-ERROR | error parsing arguments |
|
static |
Parses the given options and returns a hash of the parsed options; prints out an error message and exits the program if there are any errors.
opts | a hash where 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:
|
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 |
All arguments parsed will be removed from pgm_args, leaving only unparsed arguments (for example, file names).