From 9e8f48e03c6e9b8c3dd29d9f21098de6e572baa9 Mon Sep 17 00:00:00 2001 From: Navid Shaikh Date: Tue, 5 Nov 2019 16:26:50 +0530 Subject: [PATCH] Add completion to help message Fixes #477 --- docs/cmd/kn.md | 1 + docs/cmd/kn_completion.md | 47 ++++++++++++++++++++++++ pkg/kn/commands/completion/completion.go | 3 +- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 docs/cmd/kn_completion.md diff --git a/docs/cmd/kn.md b/docs/cmd/kn.md index 8c171ab9a9..4053f7caed 100644 --- a/docs/cmd/kn.md +++ b/docs/cmd/kn.md @@ -22,6 +22,7 @@ Manage your Knative building blocks: ### SEE ALSO +* [kn completion](kn_completion.md) - Output shell completion code * [kn plugin](kn_plugin.md) - Plugin command group * [kn revision](kn_revision.md) - Revision command group * [kn route](kn_route.md) - Route command group diff --git a/docs/cmd/kn_completion.md b/docs/cmd/kn_completion.md new file mode 100644 index 0000000000..054ec57c6d --- /dev/null +++ b/docs/cmd/kn_completion.md @@ -0,0 +1,47 @@ +## kn completion + +Output shell completion code + +### Synopsis + + +This command prints shell completion code which needs to be evaluated +to provide interactive completion + +Supported Shells: + - bash + - zsh + +``` +kn completion [SHELL] [flags] +``` + +### Examples + +``` + + # Generate completion code for bash + source <(kn completion bash) + + # Generate completion code for zsh + source <(kn completion zsh) +``` + +### Options + +``` + -h, --help help for completion +``` + +### Options inherited from parent commands + +``` + --config string kn config file (default is $HOME/.kn/config.yaml) + --kubeconfig string kubectl config file (default is $HOME/.kube/config) + --log-http log http traffic +``` + +### SEE ALSO + +* [kn](kn.md) - Knative client + diff --git a/pkg/kn/commands/completion/completion.go b/pkg/kn/commands/completion/completion.go index 6edcb0d7aa..e45358fba5 100644 --- a/pkg/kn/commands/completion/completion.go +++ b/pkg/kn/commands/completion/completion.go @@ -25,7 +25,7 @@ import ( const ( desc = ` -This command prints shell completion code which need to be evaluated +This command prints shell completion code which needs to be evaluated to provide interactive completion Supported Shells: @@ -47,7 +47,6 @@ func NewCompletionCommand(p *commands.KnParams) *cobra.Command { Long: desc, ValidArgs: []string{"bash", "zsh"}, Example: eg, - Hidden: true, // Don't show this in help listing Run: func(cmd *cobra.Command, args []string) { if len(args) == 1 { switch args[0] {