pub trait CliCommand {
    fn update_ctx(&self, _matches: &ArgMatches, _ctx: &mut Ctx) -> Result<()> { ... }
    fn run(&self, _ctx: &mut Ctx) -> Result<()> { ... }
    fn next_subcmd<'a>(
        &self,
        _matches: &'a ArgMatches
    ) -> Option<(Box<dyn CliCommand>, &'a ArgMatches)> { ... } }

Provided Methods§

Care should be taken to keep CliCommand::update_ctx pure with no external effects such as I/O. This allows the CLI to be fully tested without any assumptions of the testing environment

Implementations§

Performs three steps:

  • calls self.update_ctx()
  • calls self.run()
  • Gets the next subcommand (if any) by calling self.next_subcmd() and calls traverse_exec on that subcommand.

This walks down the entire used subcommand hierarchy ensuring the update_ctx was called prior to run and that any deeper subcommands were executed.

Implementors§