pub trait Flag: Default + Sealed { }Expand description
Types that track the presence of a command-line flag without argument.
This trait is implemented for types that can be used with #[larpa(flag)] to either
track the presence of, or count the number of times a command-line flag is specified.
This includes all built-in integer types and bool, but also Option<bool>, which will be
None if the flag isn’t encountered at all, or Some if it is.
§Example
Accept a --verbose flag that can be specified multiple times:
use larpa::Command;
#[derive(Debug, PartialEq, Command)]
struct MyCmd {
#[larpa(flag, name = ["--verbose", "-v"])]
verbosity: u8,
}
assert_eq!(MyCmd::from_iter(["my-cmd"]), MyCmd { verbosity: 0 });
assert_eq!(MyCmd::from_iter(["my-cmd", "--verbose"]), MyCmd { verbosity: 1 });
assert_eq!(MyCmd::from_iter(["my-cmd", "-v"]), MyCmd { verbosity: 1 });
assert_eq!(MyCmd::from_iter(["my-cmd", "-vvv"]), MyCmd { verbosity: 3 });Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.