pub struct ArgSpec {
pub argument_id: String,
pub syntax: ArgSyntax,
pub value_type: ArgValueType,
pub value_name: Option<String>,
pub enum_values: Vec<String>,
pub range: Option<[i64; 2]>,
pub default: Option<CliValue>,
pub repeatable: bool,
pub sensitive: bool,
pub about: Option<String>,
}Expand description
One command-local application argument.
Fields§
§argument_id: String§syntax: ArgSyntax§value_type: ArgValueType§value_name: Option<String>§enum_values: Vec<String>§range: Option<[i64; 2]>Inclusive bounds for an I64 argument.
Lets a registry say 1..=1000 without a host-supplied parser, so a
count that must fit an i32, a usize, or a NonZero is rejected at
exit 2 with the other usage errors rather than checked again inside the
handler — where the only honest report left is a domain failure.
default: Option<CliValue>§repeatable: bool§sensitive: boolThis argument’s value must never be echoed back.
The core only consumes the bit: it suppresses help defaults, keeps the
value out of rendered templates, and rejects a serializable default.
Which arguments deserve it is a host convention — crate::cli_afdata
derives it from AFDATA’s _secret suffix.
about: Option<String>Implementations§
Source§impl ArgSpec
impl ArgSpec
pub fn flag(long: impl Into<String>) -> Self
pub fn option(long: impl Into<String>, value_name: impl Into<String>) -> Self
pub fn option_i64( long: impl Into<String>, value_name: impl Into<String>, ) -> Self
pub fn option_f64( long: impl Into<String>, value_name: impl Into<String>, ) -> Self
pub fn option_json( long: impl Into<String>, value_name: impl Into<String>, ) -> Self
pub fn option_enum<I, S>(long: impl Into<String>, values: I) -> Self
Sourcepub fn uuid(self) -> Self
pub fn uuid(self) -> Self
Read this argument as a canonical RFC 4122 UUID.
The resolved value is still a CliValue::String; what changes is that a
malformed one is rejected as a usage error before the command runs.
Sourcepub fn range(self, minimum: i64, maximum: i64) -> Self
pub fn range(self, minimum: i64, maximum: i64) -> Self
Constrain an I64 argument to an inclusive range.
Use it for a count that must fit a narrower integer than i64 — the
check then reports as a usage error, beside the other argument
failures, rather than as a domain failure from inside the handler.
pub fn positional( argument_id: impl Into<String>, index: usize, value_name: impl Into<String>, ) -> Self
pub fn positional_json( argument_id: impl Into<String>, index: usize, value_name: impl Into<String>, ) -> Self
pub fn positional_enum<I, S>( argument_id: impl Into<String>, index: usize, value_name: impl Into<String>, values: I, ) -> Self
pub fn value_name(self, value_name: impl Into<String>) -> Self
pub fn default(self, value: impl Into<String>) -> Self
pub fn default_i64(self, value: i64) -> Self
pub fn default_f64(self, value: f64) -> Self
pub fn repeatable(self) -> Self
Sourcepub fn sensitive(self) -> Self
pub fn sensitive(self) -> Self
Mark this argument’s value as one that must never be echoed back.