pub struct Arg {
pub long: Option<&'static str>,
pub short: Option<char>,
pub negatable: bool,
pub repeatable: bool,
pub value_name: &'static str,
pub position: Option<u16>,
}Expand description
The argument-vector binding: the flag a value may arrive under.
How many values the flag takes is not declared here — it follows from the
input’s crate::Type. A boolean flag takes none and means true by its
presence; anything else takes exactly one. Deriving it removes a field that
could contradict the type, and the derived arity is still written out
explicitly in the published contract so no other language has to re-derive it.
Fields§
§long: Option<&'static str>The long form without dashes, e.g. "log-level" for --log-level.
Mutually exclusive with position — see Arg::positional.
short: Option<char>The short form without its dash, e.g. 'l' for -l.
Mutually exclusive with position — see Arg::positional.
negatable: boolWhether --no-<long> is accepted to force the value off. Booleans only.
repeatable: boolWhether the flag may be repeated, accumulating values. Lists only.
value_name: &'static strThe placeholder shown in help for the value, e.g. "LEVEL" in
--log-level <LEVEL>. Ignored for booleans, which take no value.
position: Option<u16>A bare positional slot instead of a --flag, addressed by position
rather than by name — see Arg::positional.
For an input with an empty crate::Input::subcommands list, this is
the position among all positionals in the invocation (Some(0) is the
first). For an input scoped to one or more subcommands, it is the
position after the subcommand token itself — Some(0) is the first
positional following the subcommand, letting two different
subcommands each use their own Some(0) without conflict, since only
one subcommand is ever active in a given invocation.
Implementations§
Source§impl Arg
impl Arg
Sourcepub const fn long(long: &'static str) -> Arg
pub const fn long(long: &'static str) -> Arg
A long flag, e.g. Arg::long("log-level") for --log-level.
Sourcepub const fn pair(long: &'static str, short: char) -> Arg
pub const fn pair(long: &'static str, short: char) -> Arg
Both forms, e.g. Arg::pair("log-level", 'l').
Sourcepub const fn positional(position: u16) -> Arg
pub const fn positional(position: u16) -> Arg
A bare positional, e.g. Arg::positional(0) for the first one.
Not a --flag: consumed by position in argv, the same slot a
resolver’s positionals list already collects (see argenv-resolve)
— this lets a specific one be declared, typed, and documented like
any other input.