Skip to content

Commit

Permalink
fix(PowerShell Completions): fixes a bug where powershells completion…
Browse files Browse the repository at this point in the history
…s cant be used if no subcommands are defined

Closes #931
  • Loading branch information
kbknapp committed Apr 19, 2017
1 parent 3f44dd4 commit a8bce55
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/completions/powershell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,6 +44,9 @@ impl<'a, 'b> PowerShellGen<'a, 'b> {
%{{
switch ($_.ToString()) {{
{subcommands_detection_cases}
default {{
break
}}
}}
}}
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a8bce55

Please sign in to comment.