pub struct CommandCollection {
pub base: Group,
pub sources: Vec<Group>,
}Expand description
A group-like command that merges commands from multiple groups.
This is the click-rs equivalent of Python Click’s CommandCollection.
Commands are resolved by searching the base group first, then each source
group in insertion order.
Only the base group’s parameters (options/arguments/callback/help) are used.
Fields§
§base: GroupThe base group providing parameters and help formatting.
sources: Vec<Group>Additional groups to source subcommands from.
Implementations§
Source§impl CommandCollection
impl CommandCollection
Sourcepub fn new(name: &str) -> CommandCollectionBuilder
pub fn new(name: &str) -> CommandCollectionBuilder
Create a new CommandCollection builder with the given base name.
The base group can register its own subcommands via .command(...).
Sourcepub fn add_source(&mut self, group: Group)
pub fn add_source(&mut self, group: Group)
Add a source group.
Sourcepub fn get_command(&self, name: &str) -> Option<&dyn CommandLike>
pub fn get_command(&self, name: &str) -> Option<&dyn CommandLike>
Get a subcommand by name, searching base first then sources.
Sourcepub fn list_commands(&self) -> Vec<String>
pub fn list_commands(&self) -> Vec<String>
List all unique subcommand names from base + sources, sorted.
Trait Implementations§
Source§impl CommandLike for CommandCollection
impl CommandLike for CommandCollection
Source§fn make_context(
&self,
info_name: &str,
args: Vec<String>,
parent: Option<Arc<Context>>,
) -> Result<Context, ClickError>
fn make_context( &self, info_name: &str, args: Vec<String>, parent: Option<Arc<Context>>, ) -> Result<Context, ClickError>
Create a context for executing this command. Read more
Source§fn invoke(&self, ctx: &Context) -> Result<(), ClickError>
fn invoke(&self, ctx: &Context) -> Result<(), ClickError>
Invoke the command with the given context.
Source§fn main(&self, args: Vec<String>) -> Result<(), ClickError>
fn main(&self, args: Vec<String>) -> Result<(), ClickError>
Main entry point - make context, parse args, and invoke.
Source§fn get_short_help(&self) -> String
fn get_short_help(&self) -> String
Get the short help text for command listings.
Check if this command is hidden from help output.
Auto Trait Implementations§
impl !RefUnwindSafe for CommandCollection
impl !UnwindSafe for CommandCollection
impl Freeze for CommandCollection
impl Send for CommandCollection
impl Sync for CommandCollection
impl Unpin for CommandCollection
impl UnsafeUnpin for CommandCollection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more