Parses a list of command‐line arguments, passed in the argc and argv[] parameters, into a set of Abseil Flag values, returning any unparsed arguments in positional_args and unrecognized_flags output parameters.

Synopsis

Declared in <absl/flags/parse.h>

void
ParseAbseilFlagsOnly(
    int argc,
    char* argv[],
    std::vector<char*>& positional_args,
    std::vector<UnrecognizedFlag>& unrecognized_flags);

Description

This function classifies all the arguments (including content of the flagfiles, if any) into one of the following groups:

* arguments specified as "‐‐flag=value" or "‐‐flag value" that match registered or built‐in Abseil Flags. These are "Abseil Flag arguments." * arguments specified as "‐‐flag" that are unrecognized as Abseil Flags * arguments that are not specified as "‐‐flag" are positional arguments * arguments that follow the flag‐terminating delimiter (‐‐) are also treated as positional arguments regardless of their syntax.

All of the deduced Abseil Flag arguments are then parsed into their corresponding flag values. If any syntax errors are found in these arguments, the binary exits with code 1.

This function also handles Abseil Flags built‐in usage flags (e.g. ‐‐help) if any were present on the command line.

All the remaining positional arguments including original program name (argv[0]) are are returned in the positional_args output parameter.

All unrecognized flags that are not otherwise ignored are returned in the unrecognized_flags output parameter. Note that the special undefok flag allows you to specify flags which can be safely ignored; undefok specifies these flags as a comma‐separated list. Any unrecognized flags that appear within undefok will therefore be ignored and not included in the unrecognized_flag output parameter.

Parameters

Name

Description

argc

The number of command‐line arguments, as passed to main().

argv

The command‐line arguments, as passed to main().

positional_args

Receives the remaining positional arguments.

unrecognized_flags

Receives the flags that were not recognized.

Created with MrDocs