summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAnthony Fok <foka@debian.org>2021-02-09 13:37:36 -0700
committerAnthony Fok <foka@debian.org>2021-02-09 13:37:36 -0700
commit5f621df2570236a08cd21e8dd1c60502ec3db328 (patch)
tree484aba2aa7aeb61c6c11236026b18b5f8518dd76 /commands
parent7118f89cf35246767e26dcb5e747469ffa61f473 (diff)
commands: Add PowerShell completion support
Revert "Refactor: Remove powershell support" with fixes Thanks to Ben Mezger (@benmezger) for the original code. See #8122 This reverts commit a7c515e1b56e8cab34ca2647b4116904df9c8250.
Diffstat (limited to 'commands')
-rw-r--r--commands/genautocomplete.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/commands/genautocomplete.go b/commands/genautocomplete.go
index 3f3bf9c87..9806ca447 100644
--- a/commands/genautocomplete.go
+++ b/commands/genautocomplete.go
@@ -25,8 +25,10 @@ var _ cmder = (*genautocompleteCmd)(nil)
type genautocompleteCmd struct {
autocompleteTarget string
- // bash, zsh or fish
+
+ // bash, zsh, fish or powershell
autocompleteType string
+
*baseCmd
}
@@ -46,7 +48,7 @@ for convenience, and the command may need superuser rights, e.g.:
Add ` + "`--completionfile=/path/to/file`" + ` flag to set alternative
file-path and name.
-Add ` + "`--type={bash, zsh or fish}`" + ` flag to set alternative
+Add ` + "`--type={bash, zsh, fish or powershell}`" + ` flag to set alternative
shell type.
Logout and in again to reload the completion scripts,
@@ -65,12 +67,14 @@ or just source them in directly:
}
switch cc.autocompleteType {
- case "zsh":
- err = cmd.Root().GenZshCompletion(target)
case "bash":
err = cmd.Root().GenBashCompletion(target)
+ case "zsh":
+ err = cmd.Root().GenZshCompletion(target)
case "fish":
err = cmd.Root().GenFishCompletion(target, true)
+ case "powershell":
+ err = cmd.Root().GenPowerShellCompletion(target)
default:
return newUserError("Unsupported completion type")
}
@@ -87,7 +91,7 @@ or just source them in directly:
})
cc.cmd.PersistentFlags().StringVarP(&cc.autocompleteTarget, "completionfile", "f", "", "autocompletion file, defaults to stdout")
- cc.cmd.PersistentFlags().StringVarP(&cc.autocompleteType, "type", "t", "bash", "autocompletion type (zsh, bash or fish)")
+ cc.cmd.PersistentFlags().StringVarP(&cc.autocompleteType, "type", "t", "bash", "autocompletion type (bash, zsh, fish, or powershell)")
return cc
}