GetOptions parses an argument list for requested arguments given by an
OptionList.
This supports short and long options:
Short Options have the following characteristics.
- A single dash, '-', starts a flag or a flag sequence. An example of a
flag is '-c' and a flag sequence is '-xyz'.
- A flag may have a required argument. The flag may or may not be separated
by a space from it's argument. For example, both -fbar and -f bar are
acceptable.
- A flag may have an optional argument. The flag must not be separated by a
space from it's optional argument. For example, -fbar is acceptable provides
bar as the argument, but -f bar has bar as a non-option argument.
- These rules can combine. For example, -xyzfoo can be the same as -x -y -z
foo
- If an Option expects an argument, then that argument can have a leading
'-'. That is, if -x requires an option then the argument -y can be given as
-x-y or -x -y.
Long Options have the following characteristics:
- A double dash '--' starts a single flag. For example --print. Note, a
long option is typically descriptive, but can be a single character.
- An argument may be given in one of two ways --file=filename or --file
filename. That is, separated by an '=' sign or whitespace.
Note:
- Options can be repeated. What that means is up to the program.
- The '--' sequence terminates argument processing.
- A '-' by itself is not a flag.
- Unrecognized flags are an error.
- Unrecognized arguments are moved after the processed flags.