-
OPT__ABBREV(&int_var)
-
Add --abbrev[=<n>].
-
OPT__COLOR(&int_var, description)
-
Add --color[=<when>] and --no-color.
-
OPT__DRY_RUN(&int_var, description)
-
Add -n, --dry-run.
-
OPT__FORCE(&int_var, description)
-
Add -f, --force.
-
OPT__QUIET(&int_var, description)
-
Add -q, --quiet.
-
OPT__VERBOSE(&int_var, description)
-
Add -v, --verbose.
-
OPT_GROUP(description)
-
Start an option group. description is a short string that
describes the group or an empty string.
Start the description with an upper-case letter.
-
OPT_BOOL(short, long, &int_var, description)
-
Introduce a boolean option. int_var is set to one with
--option and set to zero with --no-option.
-
OPT_COUNTUP(short, long, &int_var, description)
-
Introduce a count-up option.
Each use of --option increments int_var, starting from zero
(even if initially negative), and --no-option resets it to
zero. To determine if --option or --no-option was encountered at
all, initialize int_var to a negative value, and if it is still
negative after parse_options(), then neither --option nor
--no-option was seen.
-
OPT_BIT(short, long, &int_var, description, mask)
-
Introduce a boolean option.
If used, int_var is bitwise-ored with mask.
-
OPT_NEGBIT(short, long, &int_var, description, mask)
-
Introduce a boolean option.
If used, int_var is bitwise-anded with the inverted mask.
-
OPT_SET_INT(short, long, &int_var, description, integer)
-
Introduce an integer option.
int_var is set to integer with --option, and
reset to zero with --no-option.
-
OPT_STRING(short, long, &str_var, arg_str, description)
-
Introduce an option with string argument.
The string argument is put into str_var.
-
OPT_STRING_LIST(short, long, &struct string_list, arg_str, description)
-
Introduce an option with string argument.
The string argument is stored as an element in string_list.
Use of --no-option will clear the list of preceding values.
-
OPT_INTEGER(short, long, &int_var, description)
-
Introduce an option with integer argument.
The integer is put into int_var.
-
OPT_MAGNITUDE(short, long, &unsigned_long_var, description)
-
Introduce an option with a size argument. The argument must be a
non-negative integer and may include a suffix of k, m or g to
scale the provided value by 1024, 10242 or 10243 respectively.
The scaled value is put into unsigned_long_var.
-
OPT_EXPIRY_DATE(short, long, ×tamp_t_var, description)
-
Introduce an option with expiry date argument, see parse_expiry_date().
The timestamp is put into timestamp_t_var.
-
OPT_CALLBACK(short, long, &var, arg_str, description, func_ptr)
-
Introduce an option with argument.
The argument will be fed into the function given by func_ptr
and the result will be put into var.
See Option Callbacks below for a more elaborate description.
-
OPT_FILENAME(short, long, &var, description)
-
Introduce an option with a filename argument.
The filename will be prefixed by passing the filename along with
the prefix argument of parse_options() to prefix_filename().
-
OPT_NUMBER_CALLBACK(&var, description, func_ptr)
-
Recognize numerical options like -123 and feed the integer as
if it was an argument to the function given by func_ptr.
The result will be put into var. There can be only one such
option definition. It cannot be negated and it takes no
arguments. Short options that happen to be digits take
precedence over it.
-
OPT_COLOR_FLAG(short, long, &int_var, description)
-
Introduce an option that takes an optional argument that can
have one of three values: "always", "never", or "auto". If the
argument is not given, it defaults to "always". The --no- form
works like --long=never; it cannot take an argument. If
"always", set int_var to 1; if "never", set int_var to 0; if
"auto", set int_var to 1 if stdout is a tty or a pager,
0 otherwise.
-
OPT_NOOP_NOARG(short, long)
-
Introduce an option that has no effect and takes no arguments.
Use it to hide deprecated options that are still to be recognized
and ignored silently.
-
OPT_PASSTHRU(short, long, &char_var, arg_str, description, flags)
-
Introduce an option that will be reconstructed into a char* string,
which must be initialized to NULL. This is useful when you need to
pass the command-line option to another command. Any previous value
will be overwritten, so this should only be used for options where
the last one specified on the command line wins.
-
OPT_PASSTHRU_ARGV(short, long, &strvec_var, arg_str, description, flags)
-
Introduce an option where all instances of it on the command-line will
be reconstructed into a strvec. This is useful when you need to
pass the command-line option, which can be specified multiple times,
to another command.
-
OPT_CMDMODE(short, long, &int_var, description, enum_val)
-
Define an "operation mode" option, only one of which in the same
group of "operating mode" options that share the same int_var
can be given by the user. int_var is set to enum_val when the
option is used, but an error is reported if other "operating mode"
option has already set its value to the same int_var.
In new commands consider using subcommands instead.
-
OPT_SUBCOMMAND(long, &fn_ptr, subcommand_fn)
-
Define a subcommand. subcommand_fn is put into fn_ptr when
this subcommand is used.