diff --git a/README.md b/README.md index 86a77d66b6..614fd074f0 100644 --- a/README.md +++ b/README.md @@ -480,11 +480,11 @@ eStargz-optimized images. ## Does `ko` support autocompletion? -Yes! `ko completion` generates a Bash completion script, which you can add to -your `bash_completion` directory: +Yes! `ko completion` generates a Bash/Zsh/Fish/PowerShell completion script. +You can get how to load it from help document. ``` -ko completion > /usr/local/etc/bash_completion.d/ko +ko completion [bash|zsh|fish|powershell] --help ``` Or, you can source it directly: diff --git a/doc/ko.md b/doc/ko.md index c835801fb2..40c6099fdb 100644 --- a/doc/ko.md +++ b/doc/ko.md @@ -16,7 +16,6 @@ ko [flags] * [ko apply](ko_apply.md) - Apply the input files with image references resolved to built/pushed image digests. * [ko build](ko_build.md) - Build and publish container images from the given importpaths. -* [ko completion](ko_completion.md) - Output shell completion code (default Bash) * [ko create](ko_create.md) - Create the input files with image references resolved to built/pushed image digests. * [ko delete](ko_delete.md) - See "kubectl help delete" for detailed usage. * [ko deps](ko_deps.md) - Print Go module dependency information about the ko-built binary in the image diff --git a/doc/ko_completion.md b/doc/ko_completion.md deleted file mode 100644 index cfa18500c4..0000000000 --- a/doc/ko_completion.md +++ /dev/null @@ -1,19 +0,0 @@ -## ko completion - -Output shell completion code (default Bash) - -``` -ko completion [flags] -``` - -### Options - -``` - -h, --help help for completion - --zsh Generates completion code for Zsh shell. -``` - -### SEE ALSO - -* [ko](ko.md) - Rapidly iterate with Go, Containers, and Kubernetes. - diff --git a/pkg/commands/commands.go b/pkg/commands/commands.go index 980a6ac0a0..f0d4289cfb 100644 --- a/pkg/commands/commands.go +++ b/pkg/commands/commands.go @@ -32,7 +32,6 @@ func AddKubeCommands(topLevel *cobra.Command) { addBuild(topLevel) addRun(topLevel) addDeps(topLevel) - addCompletion(topLevel) } // check if kubectl is installed diff --git a/pkg/commands/completion.go b/pkg/commands/completion.go deleted file mode 100644 index 28858fea99..0000000000 --- a/pkg/commands/completion.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2018 Google LLC All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package commands - -import ( - "os" - - "github.com/spf13/cobra" -) - -type CompletionFlags struct { - Zsh bool -} - -func addCompletion(topLevel *cobra.Command) { - var completionFlags CompletionFlags - - completionCmd := &cobra.Command{ - Use: "completion", - Short: "Output shell completion code (default Bash)", - Run: func(cmd *cobra.Command, args []string) { - if completionFlags.Zsh { - cmd.Root().GenZshCompletion(os.Stdout) - } else { - cmd.Root().GenBashCompletion(os.Stdout) - } - }, - } - - completionCmd.Flags().BoolVar(&completionFlags.Zsh, "zsh", false, "Generates completion code for Zsh shell.") - topLevel.AddCommand(completionCmd) -}