Skip to main content

CommandCollection

Struct CommandCollection 

Source
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: Group

The base group providing parameters and help formatting.

§sources: Vec<Group>

Additional groups to source subcommands from.

Implementations§

Source§

impl CommandCollection

Source

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(...).

Source

pub fn add_source(&mut self, group: Group)

Add a source group.

Source

pub fn get_command(&self, name: &str) -> Option<&dyn CommandLike>

Get a subcommand by name, searching base first then sources.

Source

pub fn list_commands(&self) -> Vec<String>

List all unique subcommand names from base + sources, sorted.

Trait Implementations§

Source§

impl CommandLike for CommandCollection

Source§

fn name(&self) -> Option<&str>

Get the name of this command.
Source§

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>

Invoke the command with the given context.
Source§

fn main(&self, args: Vec<String>) -> Result<(), ClickError>

Main entry point - make context, parse args, and invoke.
Source§

fn get_help(&self, ctx: &Context) -> String

Get the full help text for this command.
Source§

fn get_short_help(&self) -> String

Get the short help text for command listings.
Source§

fn is_hidden(&self) -> bool

Check if this command is hidden from help output.
Source§

fn get_usage(&self, ctx: &Context) -> String

Get the usage line for this command.
Source§

fn as_any(&self) -> &dyn Any

Convert to Any for downcasting.
Source§

impl Debug for CommandCollection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.