Skip to content

Commit 073e590

Browse files
authored
feat(completion): Add support for powershell completion (#1408)
This commit is to add support for powershell completion script. Note: PowerShell v5.0+ is required
1 parent 70cd9ba commit 073e590

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/commands/completion.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ func (e *Executor) initCompletion() {
3535
RunE: e.executeFishCompletion,
3636
}
3737
completionCmd.AddCommand(fishCmd)
38+
39+
powerShell := &cobra.Command{
40+
Use: "powershell",
41+
Short: "Output powershell completion script",
42+
RunE: e.executePowerShellCompletion,
43+
}
44+
completionCmd.AddCommand(powerShell)
3845
}
3946

4047
func (e *Executor) executeBashCompletion(cmd *cobra.Command, args []string) error {
@@ -67,3 +74,12 @@ func (e *Executor) executeFishCompletion(cmd *cobra.Command, args []string) erro
6774

6875
return nil
6976
}
77+
78+
func (e *Executor) executePowerShellCompletion(cmd *cobra.Command, args []string) error {
79+
err := cmd.Root().GenPowerShellCompletion(os.Stdout)
80+
if err != nil {
81+
return errors.Wrap(err, "generate powershell completion")
82+
}
83+
84+
return nil
85+
}

0 commit comments

Comments
 (0)