Skip to main content

Crate use_flag

Crate use_flag 

Source
Expand description

§use-flag

Primitive short, long, and boolean flag types for CLI-adjacent Rust code.

use-flag validates flag names and stores flag intent. It does not scan an argv stream, expand combined short flags, define negation policy, or implement a parser.

§Example

use use_flag::{BooleanFlag, Flag};

let flag = Flag::try_from_token("--verbose")?;
let verbose = BooleanFlag::enabled(flag);

assert!(verbose.is_enabled());
assert_eq!(verbose.flag().to_token(), "--verbose");

§Scope

Use this crate for small flag vocabulary. Use a parser framework when you need parsing, validation across multiple tokens, or derived command definitions.

Modules§

prelude
Commonly used flag primitives.

Structs§

BooleanFlag
A flag paired with a boolean state.
LongFlag
A long flag name such as verbose for --verbose.
ShortFlag
A one-character short flag such as -v.

Enums§

Flag
A primitive flag token.
FlagNameError
Validation errors for primitive flag names and tokens.

Functions§

is_valid_long_flag_name
Returns whether name is valid for a long flag without the leading --.
is_valid_short_flag
Returns whether name is valid for a short flag.