pub trait CliCommand {
// Required methods
fn process(&self, req: &CliRequest) -> Result<()>;
fn help(&self) -> CliHelpScreen;
}Expand description
Trait that all CLI commands must implement.
This trait defines the interface for CLI commands, requiring implementations
to provide both a process method for executing the command and a help method
for generating help documentation.
§Example
use falcon_cli::{CliCommand, CliRequest, CliHelpScreen};
struct MyCommand;
impl CliCommand for MyCommand {
fn process(&self, req: &CliRequest) -> anyhow::Result<()> {
println!("Executing command");
Ok(())
}
fn help(&self) -> CliHelpScreen {
CliHelpScreen::new("My Command", "myapp mycommand", "Does something useful")
}
}Required Methods§
Sourcefn process(&self, req: &CliRequest) -> Result<()>
fn process(&self, req: &CliRequest) -> Result<()>
Sourcefn help(&self) -> CliHelpScreen
fn help(&self) -> CliHelpScreen
Returns the help screen for this command.
This method should create and return a CliHelpScreen with information
about how to use the command, including parameters, flags, and examples.