From a8bce55837dc4e0fb187dc93180884a40ae09c6f Mon Sep 17 00:00:00 2001 From: Kevin K Date: Tue, 18 Apr 2017 22:54:20 -0400 Subject: [PATCH] fix(PowerShell Completions): fixes a bug where powershells completions cant be used if no subcommands are defined Closes #931 --- src/completions/powershell.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/completions/powershell.rs b/src/completions/powershell.rs index b70da452..728869ac 100644 --- a/src/completions/powershell.rs +++ b/src/completions/powershell.rs @@ -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()