Skip to content
Myr

Fix documentation (#1434)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Marc Khouzam · committed by GitHub · parent 5738d6b · Browse files · 1 file+8 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Diff stats

1 file+8 added−4 removed

  • other:+8 added−4 removed

1 file+8 added−4 removed

modified:shell_completions.md+8 added-4 removed
350 unmodified lines
351})352```353### Descriptions for completions354355`zsh`, `fish` and `powershell` allow for descriptions to annotate completion choices. For commands and flags, Cobra will provide the descriptions automatically, based on usage information. For example, using zsh:355Cobra provides support for completion descriptions. Such descriptions are supported for each shell356(however, for bash, it is only available in the [completion V2 version](#bash-completion-v2)).357For commands and flags, Cobra will provide the descriptions automatically, based on usage information.358For example, using zsh:359```360$ helm s[tab]361search -- search for a keyword in charts362show -- show information of a chart
4 unmodified lines
367$ helm s[tab]368search (search for a keyword in charts) show (show information of a chart) status (displays the status of the named release)369```370368Cobra allows you to add annotations to your own completions. Simply add the annotation text after each completion, following a `\t` separator. This technique applies to completions returned by `ValidArgs`, `ValidArgsFunction` and `RegisterFlagCompletionFunc()`. For example:371Cobra allows you to add descriptions to your own completions. Simply add the description text after each completion, following a `\t` separator. This technique applies to completions returned by `ValidArgs`, `ValidArgsFunction` and `RegisterFlagCompletionFunc()`. For example:372```go373ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {374 return []string{"harbor\tAn image registry", "thanos\tLong-term metrics"}, cobra.ShellCompDirectiveNoFileComp375}}
32 unmodified lines
408Cobra provides two versions for bash completion. The original bash completion (which started it all!) can be used by calling409`GenBashCompletion()` or `GenBashCompletionFile()`.410411A new V2 bash completion version is also available. This version can be used by calling `GenBashCompletionV2()` or409`GenBashCompletionFileV2()`. The V2 version does **not** support the legacy dynamic completion (see [Bash Completions]410(bash_completions.md)) but instead works only with the Go dynamic completion solution described in this Readme.412`GenBashCompletionFileV2()`. The V2 version does **not** support the legacy dynamic completion413(see [Bash Completions](bash_completions.md)) but instead works only with the Go dynamic completion414solution described in this document.415Unless your program already uses the legacy dynamic completion solution, it is recommended that you use the bash416completion V2 solution which provides the following extra features:417- Supports completion descriptions (like the other shells)418- Small completion script of less than 300 lines (v1 generates scripts of thousands of lines; `kubectl` for example has a bash v1 completion script of over 13K lines)
128 unmodified lines