pub trait Command: Sized {
// Required methods
fn interpret(cli: &mut Cli<Memory>) -> Result<Self>;
fn execute(self) -> Result;
}Required Methods§
Sourcefn interpret(cli: &mut Cli<Memory>) -> Result<Self>
fn interpret(cli: &mut Cli<Memory>) -> Result<Self>
Constructs the given struct by mapping the parsed representation of command-line inputs (tokens) into the appropriate data fields.
The argument discovery order must be preserved and upheld by the programmer:
- Flags (Arg::flag)
- Options (Arg::option)
- Positionals (Arg::positional)
- Subcommands (Arg::subcommand)
Failure to map the appropriate data fields in the correct order according to the method in how they recieve their data from the command-line is considered a programmer’s error and will result in a panic!.
Sourcefn execute(self) -> Result
fn execute(self) -> Result
Processes the initialized struct and its defined data for an arbitrary task.
A Command is considered a top-level process, and as such, cannot have a predefined context. For providing predefined contexts to commands, see the Subcommand trait.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.