MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / exec

Function exec

flow-quickstart/src/main.rs:50–76  ·  view source on GitHub ↗
(commands: &[Node<'static>])

Source from the content-addressed store, hash-verified

48}
49
50fn exec(commands: &[Node<'static>]) {
51 let mut index = 0;
52 while index < commands.len() {
53 let cmd = &commands[index];
54 println!("> {} [{}]", cmd.question, cmd.default);
55
56 let mut user_input = String::new();
57 stdin().read_line(&mut user_input).unwrap();
58
59 let inp = user_input.trim();
60 let result: Result<Action, &'static str>;
61 if !inp.is_empty() {
62 result = (cmd.callback)(inp);
63 } else {
64 result = (cmd.callback)(cmd.default);
65 }
66
67 match result {
68 Ok(action) => match action {
69 Action::Retry => continue,
70 Action::Next => index += 1,
71 Action::Quit => break,
72 },
73 Err(why) => panic!("{:?}", why),
74 }
75 }
76}
77
78fn make_project(s: &str) -> Result<Action, &'static str> {
79 if Path::new(s).exists() {

Callers 2

create_with_typeFunction · 0.85
mainFunction · 0.85

Calls 2

lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected