fix(PowerShell Completions): fixes a bug where powershells completions cant be used if no subcommands are defined

Closes #931
This commit is contained in:
Kevin K 2017-04-18 22:54:20 -04:00
parent 3f44dd4b91
commit a8bce55837
No known key found for this signature in database
GPG key ID: 17218E4B3692F01A

View file

@ -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()