Attribute Macro cmd_lib_cf::export_cmd [−][src]
#[export_cmd]Expand description
export the function as an command to be run by run_cmd! or run_fun!
#[export_cmd(my_cmd)]
fn foo(env: &mut CmdEnv) -> CmdResult {
let msg = format!("msg from foo(), args: {:?}\n", env.args());
writeln!(env.stderr(), "{}", msg)?;
writeln!(env.stdout(), "bar")
}
use_custom_cmd!(my_cmd);
run_cmd!(my_cmd)?;
println!("get result: {}", run_fun!(my_cmd)?);Here we export function foo as my_cmd command.