Add completion to help message (#478)

Fixes #477
This commit is contained in:
Navid Shaikh 2019-11-12 15:02:23 +05:30 committed by Knative Prow Robot
parent d66887a310
commit c4a919718d
3 changed files with 49 additions and 2 deletions

View File

@ -22,6 +22,7 @@ Manage your Knative building blocks:
### SEE ALSO ### SEE ALSO
* [kn completion](kn_completion.md) - Output shell completion code
* [kn plugin](kn_plugin.md) - Plugin command group * [kn plugin](kn_plugin.md) - Plugin command group
* [kn revision](kn_revision.md) - Revision command group * [kn revision](kn_revision.md) - Revision command group
* [kn route](kn_route.md) - Route command group * [kn route](kn_route.md) - Route command group

47
docs/cmd/kn_completion.md Normal file
View File

@ -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

View File

@ -25,7 +25,7 @@ import (
const ( const (
desc = ` 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 to provide interactive completion
Supported Shells: Supported Shells:
@ -47,7 +47,6 @@ func NewCompletionCommand(p *commands.KnParams) *cobra.Command {
Long: desc, Long: desc,
ValidArgs: []string{"bash", "zsh"}, ValidArgs: []string{"bash", "zsh"},
Example: eg, Example: eg,
Hidden: true, // Don't show this in help listing
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if len(args) == 1 { if len(args) == 1 {
switch args[0] { switch args[0] {