MCPcopy Create free account
hub / github.com/auula/falsework / test_command_add

Function test_command_add

tests/test.rs:30–56  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
descriptionMethod · 0.80
versionMethod · 0.80
authorMethod · 0.80
nameMethod · 0.80
buildMethod · 0.80
value_ofMethod · 0.80
bound_flagMethod · 0.80
add_cmdMethod · 0.80

Tested by

no test coverage detected