pub trait CommandLike: Send + Sync {
// Required methods
fn name(&self) -> Option<&str>;
fn make_context(
&self,
info_name: &str,
args: Vec<String>,
parent: Option<Arc<Context>>,
) -> Result<Context, ClickError>;
fn invoke(&self, ctx: &Context) -> Result<(), ClickError>;
fn main(&self, args: Vec<String>) -> Result<(), ClickError>;
fn get_help(&self, ctx: &Context) -> String;
fn get_short_help(&self) -> String;
fn is_hidden(&self) -> bool;
fn get_usage(&self, ctx: &Context) -> String;
fn as_any(&self) -> &dyn Any;
}Expand description
Required Methods§
Sourcefn 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.
§Arguments
info_name- The name to display in help/usageargs- The arguments to parseparent- Optional parent context for nested commands
Sourcefn invoke(&self, ctx: &Context) -> Result<(), ClickError>
fn invoke(&self, ctx: &Context) -> Result<(), ClickError>
Invoke the command with the given context.
Sourcefn main(&self, args: Vec<String>) -> Result<(), ClickError>
fn main(&self, args: Vec<String>) -> Result<(), ClickError>
Main entry point - make context, parse args, and invoke.
Sourcefn 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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".