src/cli/command.rs: improve help command completion
This commit is contained in:
parent
6949d91564
commit
793b0f4d77
|
@ -472,9 +472,10 @@ fn print_simple_completion(
|
||||||
|
|
||||||
fn print_help_completion(def: &CommandLineInterface, help_cmd: &CliCommand, args: &[String]) {
|
fn print_help_completion(def: &CommandLineInterface, help_cmd: &CliCommand, args: &[String]) {
|
||||||
|
|
||||||
|
let mut done = HashSet::new();
|
||||||
|
|
||||||
match def {
|
match def {
|
||||||
CommandLineInterface::Simple(_) => {
|
CommandLineInterface::Simple(_) => {
|
||||||
let mut done = HashSet::new();
|
|
||||||
print_simple_completion(help_cmd, &mut done, &help_cmd.arg_param, args);
|
print_simple_completion(help_cmd, &mut done, &help_cmd.arg_param, args);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -485,11 +486,19 @@ fn print_help_completion(def: &CommandLineInterface, help_cmd: &CliCommand, args
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let first = &args[0];
|
let first = &args[0];
|
||||||
|
|
||||||
|
if first.starts_with("-") {
|
||||||
|
print_simple_completion(help_cmd, &mut done, &help_cmd.arg_param, args);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(sub_cmd) = map.commands.get(first) {
|
if let Some(sub_cmd) = map.commands.get(first) {
|
||||||
print_help_completion(sub_cmd, help_cmd, &args[1..]);
|
print_help_completion(sub_cmd, help_cmd, &args[1..]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for cmd in map.commands.keys() {
|
for cmd in map.commands.keys() {
|
||||||
if cmd.starts_with(first) {
|
if cmd.starts_with(first) {
|
||||||
println!("{}", cmd);
|
println!("{}", cmd);
|
||||||
|
|
Loading…
Reference in New Issue