()
| 28 | |
| 29 | #[test] |
| 30 | fn test_command_add() { |
| 31 | let mut app = falsework::app::new(); |
| 32 | |
| 33 | app.name("Calculator") |
| 34 | .author("Leon Ding <ding@ibyte.me>") |
| 35 | .version("0.0.2") |
| 36 | .description("A command line program built with Falsework."); |
| 37 | |
| 38 | let mut command = cmd::CommandItem { |
| 39 | run: |ctx| -> Result<(), Box<dyn Error>> { |
| 40 | let x = ctx.value_of("--x").parse::<i32>().unwrap(); |
| 41 | let y = ctx.value_of("--y").parse::<i32>().unwrap(); |
| 42 | println!("{} + {} = {}", x, y, x + y); |
| 43 | Ok(()) |
| 44 | }, |
| 45 | long: "这是一个加法计算程序需要两个flag参数 --x --y", |
| 46 | short: "加法计算", |
| 47 | r#use: "add", |
| 48 | }.build(); |
| 49 | |
| 50 | command.bound_flag("--x", "加数"); |
| 51 | command.bound_flag("--y", "被加数"); |
| 52 | |
| 53 | app.add_cmd(command); |
| 54 | |
| 55 | println!("{:#?}", app); |
| 56 | } |
| 57 | |
| 58 | #[test] |
| 59 | fn test_add_commands() { |
nothing calls this directly
no test coverage detected