pub struct CLOption {
pub short: Option<String>,
pub long: Option<String>,
pub description: String,
pub takes_value: bool,
pub value_name: String,
}Expand description
A single named option (-v,--verbose, --count, etc.).
Uni’s launcher lets callers describe an option with a single comma-separated prefix string; we parse that same syntax here so port-over code reads the same.
Fields§
§short: Option<String>§long: Option<String>§description: String§takes_value: booltrue when the option consumes the next argument as its value,
false for boolean flags.
value_name: StringPlaceholder shown in help output (e.g. <val>). Ignored for flags.
Implementations§
Source§impl CLOption
impl CLOption
Sourcepub fn parse_flag(prefix: &str, description: impl Into<String>) -> Self
pub fn parse_flag(prefix: &str, description: impl Into<String>) -> Self
Parse a prefix like "-v,--verbose" into short/long tokens.
Returns a CLOption with takes_value == false (i.e. a flag).
Use CLOption::parse_option to build a value-consuming option.
Panics if the prefix produces neither a short nor long alias (e.g.
"" or "verbose" without a leading dash). Such an option can
never be matched by the parser and would collide with other
malformed options in the result map.
Sourcepub fn parse_option(prefix: &str, description: impl Into<String>) -> Self
pub fn parse_option(prefix: &str, description: impl Into<String>) -> Self
Like CLOption::parse_flag but the option consumes the next argument.
Sourcepub fn canonical(&self) -> String
pub fn canonical(&self) -> String
Canonical lookup key — the long name without dashes if present, otherwise the short name without dashes. Empty schemas are rejected at build time so one of the two is always populated.