Expand description
Common CLI flag-scanning primitives.
Minimal, dependency-light helpers for hand-rolled argument parsers that do not want to pull in a full parser crate. Each helper is generic over the command name and flag being checked, so a consuming CLI supplies its own vocabulary (command names, flag spellings) and gets consistent error wording for free.
These are not a parser framework — they scan an already-split &[String]
slice for a small, fixed set of shapes (no value, one required/optional
value, reject-everything). A product CLI composes them per-subcommand.
Structs§
- ArgParse
Error - An error produced while scanning CLI arguments.
Functions§
- parse_
bool_ flag - Scan for a single boolean flag (present or absent), rejecting anything else including duplicates.
- parse_
optional_ value_ flag - Scan for an optional
--flag valuepair. ReturnsOk(None)if the flag is absent,Ok(Some(value))if present with a value, and an error for duplicates, missing values, or unexpected trailing arguments. - parse_
required_ value_ flag - Scan for a
--flag valuepair the caller treats as required. - reject_
args - Reject a subcommand that takes no arguments at all.