From 6a78fcaa0a5451e8b9839c689b01c9264e391401 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 10 Feb 2021 17:57:11 +0100 Subject: Add powershell completions Add support for generating powershell completion files. This is especially useful for people using the podman remote client on windows. [NO TESTS NEEDED] Signed-off-by: Paul Holzinger --- cmd/podman/completion/completion.go | 8 +++++++- cmd/podman/root.go | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/completion/completion.go b/cmd/podman/completion/completion.go index a4ceab4b0..472068130 100644 --- a/cmd/podman/completion/completion.go +++ b/cmd/podman/completion/completion.go @@ -21,7 +21,7 @@ const ( var ( file string noDesc bool - shells = []string{"bash", "zsh", "fish"} + shells = []string{"bash", "zsh", "fish", "powershell"} completionCmd = &cobra.Command{ Use: fmt.Sprintf("completion [options] {%s}", strings.Join(shells, "|")), Short: "Generate shell autocompletions", @@ -76,6 +76,12 @@ func completion(cmd *cobra.Command, args []string) error { } case "fish": err = cmd.Root().GenFishCompletion(w, !noDesc) + case "powershell": + if noDesc { + err = cmd.Root().GenPowerShellCompletion(w) + } else { + err = cmd.Root().GenPowerShellCompletionWithDesc(w) + } } if err != nil { diff --git a/cmd/podman/root.go b/cmd/podman/root.go index 7722e35dd..2b77afbeb 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -3,7 +3,7 @@ package main import ( "fmt" "os" - "path" + "path/filepath" "runtime" "runtime/pprof" "strings" @@ -57,7 +57,7 @@ Options: var ( rootCmd = &cobra.Command{ - Use: path.Base(os.Args[0]) + " [options]", + Use: filepath.Base(os.Args[0]) + " [options]", Long: "Manage pods, containers and images", SilenceUsage: true, SilenceErrors: true, -- cgit v1.2.3-54-g00ecf