Macro cmd_lib::use_custom_cmd

source ยท
use_custom_cmd!() { /* proc-macro */ }
Expand description

Import user registered custom command.

fn my_cmd(env: &mut CmdEnv) -> CmdResult {
    let msg = format!("msg from foo(), args: {:?}", env.get_args());
    writeln!(env.stderr(), "{msg}")?;
    writeln!(env.stdout(), "bar")
}

use_custom_cmd!(my_cmd);
run_cmd!(my_cmd)?;

Here we import the previous defined my_cmd command, so we can run it like a normal command.