mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
fix(PowerShell Completions): fixes a bug where powershells completions cant be used if no subcommands are defined
Closes #931
This commit is contained in:
parent
3f44dd4b91
commit
a8bce55837
1 changed files with 9 additions and 1 deletions
|
@ -4,6 +4,7 @@ use std::io::Write;
|
|||
|
||||
// Internal
|
||||
use app::parser::Parser;
|
||||
use INTERNAL_ERROR_MSG;
|
||||
|
||||
pub struct PowerShellGen<'a, 'b>
|
||||
where 'a: 'b
|
||||
|
@ -43,6 +44,9 @@ impl<'a, 'b> PowerShellGen<'a, 'b> {
|
|||
%{{
|
||||
switch ($_.ToString()) {{
|
||||
{subcommands_detection_cases}
|
||||
default {{
|
||||
break
|
||||
}}
|
||||
}}
|
||||
}}
|
||||
|
||||
|
@ -71,7 +75,11 @@ impl<'a, 'b> PowerShellGen<'a, 'b> {
|
|||
|
||||
fn generate_inner<'a, 'b>(p: &Parser<'a, 'b>, previous_command_name: &str) -> (String, String) {
|
||||
debugln!("PowerShellGen::generate_inner;");
|
||||
let command_name = format!("{}_{}", previous_command_name, &p.meta.name);
|
||||
let command_name = if previous_command_name.is_empty() {
|
||||
format!("{}_{}", previous_command_name, &p.meta.bin_name.as_ref().expect(INTERNAL_ERROR_MSG))
|
||||
} else {
|
||||
format!("{}_{}", previous_command_name, &p.meta.name)
|
||||
};
|
||||
|
||||
let mut subcommands_detection_cases = if previous_command_name == "" {
|
||||
String::new()
|
||||
|
|
Loading…
Reference in a new issue