diff --git a/command/completion.go b/command/completion.go index d225082ef..866a9c3cf 100644 --- a/command/completion.go +++ b/command/completion.go @@ -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: diff --git a/command/completion_test.go b/command/completion_test.go index e8a15db56..49ca8c4db 100644 --- a/command/completion_test.go +++ b/command/completion_test.go @@ -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"` {