()
| 5 | |
| 6 | #[test] |
| 7 | fn test_command_build() { |
| 8 | |
| 9 | let mut command = cmd::CommandItem { |
| 10 | run: |ctx| -> Result<(), Box<dyn Error>> { |
| 11 | let x = ctx.value_of("--x").parse::<i32>().unwrap(); |
| 12 | let y = ctx.value_of("--y").parse::<i32>().unwrap(); |
| 13 | println!("{} + {} = {}", x, y, x + y); |
| 14 | Ok(()) |
| 15 | }, |
| 16 | long: "这是一个加法计算程序需要两个flag参数 --x --y", |
| 17 | short: "加法计算", |
| 18 | r#use: "add", |
| 19 | }.build(); |
| 20 | |
| 21 | command.bound_flag("--x", "加数"); |
| 22 | |
| 23 | command.bound_flag("--y", "被加数"); |
| 24 | |
| 25 | println!("{:#?}", command); |
| 26 | } |
| 27 | |
| 28 | |
| 29 | #[test] |
nothing calls this directly
no test coverage detected