Expand description
Command building block for click-rs.
This module provides the Command struct, which is the basic building block
of command-line interfaces in click-rs. A command handles argument parsing
and invokes a callback function with the parsed values.
§Reference
Based on Python Click’s core.py:Command class (line 873+).
§Example
use click::command::Command;
use click::context::Context;
use click::option::ClickOption;
use click::argument::Argument;
let cmd = Command::new("greet")
.help("Greet someone by name")
.option(
ClickOption::new(&["--name", "-n"])
.help("Name to greet")
.default("World")
.build()
)
.argument(
Argument::new("count")
.help("Number of times to greet")
.build()
)
.callback(|ctx| {
// Access parsed values from ctx.params()
Ok(())
})
.build();
assert_eq!(cmd.name, Some("greet".to_string()));
assert!(!cmd.hidden);Structs§
- Command
- A command is the basic building block of click-rs CLIs.
- Command
Builder - Builder for creating
Commandinstances.
Type Aliases§
- Command
Callback - Type for command callbacks.