pub struct Flag { /* private fields */ }Expand description
A flag definition for a crate::Command or app-level registration.
Flags can carry an optional short alias (e.g. "h" for "help") which is
resolved to the canonical name before the handler is called. Use Flag::global
to create a flag that is available across all commands.
Implementations§
Source§impl Flag
impl Flag
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a new command-scoped flag with the given canonical name.
The name should be given without the -- prefix, e.g. "silent" for --silent.
Sourcepub fn global(name: impl Into<String>) -> Self
pub fn global(name: impl Into<String>) -> Self
Creates a new global flag available to all commands in the app.
Global flags are resolved and merged into crate::CommandContext::flags
for every command, so handlers can read them without any extra setup.
Register global flags on the app via crate::App::flag.
§Example
use vecli::Flag;
let debug = Flag::global("debug").alias("g").description("Enable debug output.");Sourcepub fn alias(self, alias: impl Into<String>) -> Self
pub fn alias(self, alias: impl Into<String>) -> Self
Sets the short alias for this flag (e.g. "h" to match -h).
Aliases are always treated as boolean regardless of the long flag’s value type.
Sourcepub fn description(self, desc: impl Into<String>) -> Self
pub fn description(self, desc: impl Into<String>) -> Self
Sets the description shown in help output.