Skip to content

Commit a8bce55

Browse files
committed
fix(PowerShell Completions): fixes a bug where powershells completions cant be used if no subcommands are defined
Closes #931
1 parent 3f44dd4 commit a8bce55

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/completions/powershell.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use std::io::Write;
44

55
// Internal
66
use app::parser::Parser;
7+
use INTERNAL_ERROR_MSG;
78

89
pub struct PowerShellGen<'a, 'b>
910
where 'a: 'b
@@ -43,6 +44,9 @@ impl<'a, 'b> PowerShellGen<'a, 'b> {
4344
%{{
4445
switch ($_.ToString()) {{
4546
{subcommands_detection_cases}
47+
default {{
48+
break
49+
}}
4650
}}
4751
}}
4852
@@ -71,7 +75,11 @@ impl<'a, 'b> PowerShellGen<'a, 'b> {
7175

7276
fn generate_inner<'a, 'b>(p: &Parser<'a, 'b>, previous_command_name: &str) -> (String, String) {
7377
debugln!("PowerShellGen::generate_inner;");
74-
let command_name = format!("{}_{}", previous_command_name, &p.meta.name);
78+
let command_name = if previous_command_name.is_empty() {
79+
format!("{}_{}", previous_command_name, &p.meta.bin_name.as_ref().expect(INTERNAL_ERROR_MSG))
80+
} else {
81+
format!("{}_{}", previous_command_name, &p.meta.name)
82+
};
7583

7684
let mut subcommands_detection_cases = if previous_command_name == "" {
7785
String::new()

0 commit comments

Comments
 (0)