src/api/cli/command.rs - handle_nested_command: fix help output

This commit is contained in:
Dietmar Maurer 2020-01-27 11:09:14 +01:00
parent a14c7b170f
commit e8560b67f2

View File

@ -94,7 +94,7 @@ async fn handle_nested_command(
// Note: Avoid async recursive function, because current rust compiler cant handle that // Note: Avoid async recursive function, because current rust compiler cant handle that
loop { loop {
if args.is_empty() { if args.is_empty() {
let mut cmds: Vec<&String> = def.commands.keys().collect(); let mut cmds: Vec<&String> = map.commands.keys().collect();
cmds.sort(); cmds.sort();
let list = cmds.iter().fold(String::new(), |mut s, item| { let list = cmds.iter().fold(String::new(), |mut s, item| {
@ -106,7 +106,7 @@ async fn handle_nested_command(
}); });
let err_msg = format!("no command specified.\nPossible commands: {}", list); let err_msg = format!("no command specified.\nPossible commands: {}", list);
print_nested_usage_error(&prefix, def, &err_msg); print_nested_usage_error(&prefix, map, &err_msg);
return Err(format_err!("{}", err_msg)); return Err(format_err!("{}", err_msg));
} }
@ -116,7 +116,7 @@ async fn handle_nested_command(
Some(cmd) => cmd, Some(cmd) => cmd,
None => { None => {
let err_msg = format!("no such command '{}'", command); let err_msg = format!("no such command '{}'", command);
print_nested_usage_error(&prefix, def, &err_msg); print_nested_usage_error(&prefix, map, &err_msg);
return Err(format_err!("{}", err_msg)); return Err(format_err!("{}", err_msg));
} }
}; };