Skip to main content

Module flags

Module flags 

Source
Expand description

Command-line flag helpers for clap: the flag kinds the gadk deploy commands register (string, int, duration and bool flags) as clap builder Args that parse like ADK’s CLI flags, the value readers, passed (the flag was on the command line) and the mapping of clap’s parse errors to ADK’s error texts (pflag_error).

Rules reproduced: --f=v and --f v, -f v, -fv and -f=v; a value-taking flag takes the next argument even when it starts with -; a bool flag takes a value only as --b=v, so --b v sets it true and leaves v as an argument; a repeated flag keeps its last value; ints are parsed with the base chosen by the prefix (0x, 0o, 0b, a leading 0 for octal, else decimal) into an i64, bools accept 1 t T TRUE true True 0 f F FALSE false False, and durations are signed sequences of decimal numbers with unit suffixes (ns, us, ms, s, m, h) such as 2h45m; stray positional arguments are accepted and ignored.

Constants§

STRAY_ARGS
The id of the hidden trailing positional that swallows stray arguments.

Functions§

bool_flag
A bool flag: --b is true, --b=<v> takes a bool value (1 t T TRUE true True 0 f F FALSE false False); a value is never taken from the next argument.
bool_value
A bool_flag’s value.
duration_flag
A duration flag: the value is a signed sequence of decimal numbers with unit suffixes (ns, us, ms, s, m, h); default is the text form of the default (e.g. 1s, 8760h0m0s).
duration_value
A duration_flag’s value.
int_flag
An int flag: the value is an i64 with the base chosen by its prefix (0x, 0o, 0b, a leading 0 for octal, else decimal).
int_value
An int_flag’s value.
passed
Whether the flag was on the command line.
pflag_command
A subcommand whose flags are POSIX-style: a repeated flag overrides the earlier value instead of being a clap error, and there is no help subcommand (only the root has one).
pflag_error
ADK’s error text for clap’s parse error e on cmd (the subcommand being parsed); raw are the command-line arguments, used where clap does not keep what ADK’s text reports (the token an unknown shorthand came from, whether a value-less flag was written short). Errors with no ADK text keep clap’s message.
stray_args
The hidden trailing positional: commands without a positional-argument validator accept and ignore positional arguments.
string_flag
A string flag.
string_value
A string_flag’s value (its default when absent).