Go to the first, previous, next, last section, table of contents.


Specifying Options in an Argp Parser

The options field in a struct argp points to a vector of struct argp_option structures, each of which specifies an option that argp parser supports (actually, sometimes multiple entries may used for a single option if it has many names). It should be terminated by an entry with zero in all fields (note that when using an initialized C array for options, writing { 0 } is enough to achieve this).

Data Type: struct argp_option
This structure specifies a single option that an argp parser understands, and how to parse and document it. It has the following fields:

const char *name
The long name for this option, corresponding to the long option `--name'; this field can be zero if this option only has a short name. To specify multiple names for an option, additional entries may follow this one, with the OPTION_ALIAS flag set (see section Flags for Argp Options).
int key
The integer key that is provided to the argp parser's parsing function when this option is being parsed. Also, if key has a value that is a printable ASCII character (i.e., isascii (key) is true), it also specifies a short option `-char', where char is the ASCII character with the code key.
const char *arg
If non-zero, this is the name of an argument associated with this option, which must be provided (e.g., with the `--name=value' or `-char value' syntaxes) unless the OPTION_ARG_OPTIONAL flag (see section Flags for Argp Options) is set, in which case it may be provided.
int flags
Flags associated with this option (some of which are referred to above). See section Flags for Argp Options.
const char *doc
A documentation string for this option, for printing in help messages. If both the name and key fields are zero, this string will be printed out-dented from the normal option column, making it useful as a group header (it will be the first thing printed in its group); in this usage, it's conventional to end the string with a `:' character.
int group
The group this option is in. In a long help message, options are sorted alphabetically within each group, and the groups presented in the order 0, 1, 2, ..., n, -m, ..., -2, -1. Every entry in an options array with this field 0 will inherit the group number of the previous entry, or zero if it's the first one, unless its a group header (name and key fields both zero), in which case, the previous entry + 1 is the default. Automagic options such as `--help' are put into group -1. Note that because of C structure initialization rules, this field often need not be specified, because 0 is the right value.


Go to the first, previous, next, last section, table of contents.