Attribute Macro cmd_lib::export_cmd [−][src]
#[export_cmd]
export the function as an command to be run by run_cmd!
or run_fun!
#[export_cmd(my_cmd)] fn foo(args: CmdArgs, _envs: CmdEnvs, io: &mut CmdStdio) -> CmdResult { let msg = format!("msg from foo(), args: {:?}\n", args); io.errbuf.push_str(&msg); io.outbuf.push_str("bar"); Ok(()) } 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.