Add support for PowerShell completion

This commit is contained in:
Mislav Marohnić 2020-03-05 09:33:49 +01:00
parent 535f7546ac
commit aa07c5366e
2 changed files with 13 additions and 0 deletions

View file

@ -36,6 +36,8 @@ When installing with Homebrew, see https://docs.brew.sh/Shell-Completion
return RootCmd.GenBashCompletion(cmd.OutOrStdout())
case "zsh":
return RootCmd.GenZshCompletion(cmd.OutOrStdout())
case "powershell":
return RootCmd.GenPowerShellCompletion(cmd.OutOrStdout())
case "fish":
return cobrafish.GenCompletion(RootCmd, cmd.OutOrStdout())
default:

View file

@ -38,6 +38,17 @@ func TestCompletion_fish(t *testing.T) {
}
}
func TestCompletion_powerShell(t *testing.T) {
output, err := RunCommand(completionCmd, `completion -s powershell`)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(output.String(), "Register-ArgumentCompleter") {
t.Errorf("problem in fish completion:\n%s", output)
}
}
func TestCompletion_unsupported(t *testing.T) {
_, err := RunCommand(completionCmd, `completion -s csh`)
if err == nil || err.Error() != `unsupported shell type "csh"` {