Expand description
Command groups for click-rs.
This module provides the Group struct, which is a command that contains
and dispatches to subcommands. Groups can be nested to create hierarchical
command-line interfaces.
§Reference
Based on Python Click’s core.py:Group class (line 1503+).
§Example
use click::group::{Group, CommandLike};
use click::command::Command;
use click::context::Context;
let cli = Group::new("cli")
.help("A sample CLI application")
.command(
Command::new("init")
.help("Initialize the project")
.callback(|_ctx| {
println!("Initializing...");
Ok(())
})
.build()
)
.command(
Command::new("build")
.help("Build the project")
.callback(|_ctx| {
println!("Building...");
Ok(())
})
.build()
)
.build();
assert_eq!(cli.list_commands().len(), 2);Structs§
- Command
Collection - A group-like command that merges commands from multiple groups.
- Command
Collection Builder - Builder for
CommandCollection. - Group
- A command group that contains and dispatches to subcommands.
- Group
Builder - Builder for creating
Groupinstances.
Traits§
- Command
Like - Shared interface for Command and Group.
Type Aliases§
- Result
Callback - Type for result callbacks that process subcommand return values.