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
Provenance
- Commit
07861c8- Tree
a7f9a16- Author
Marc Khouzam <marc.khouzam@montreal.ca>- Committer
GitHub <noreply@github.com>- Parent
5738d6b
1 file changed+8 added−4 removed
modified:shell_completions.md+8 added-4 removed
350 unmodified lines351 })352 ```353 ### Descriptions for completions354 355-`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:355+Cobra 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)).357+For commands and flags, Cobra will provide the descriptions automatically, based on usage information.358+For example, using zsh:359 ```360 $ helm s[tab]361 search -- search for a keyword in charts362 show -- show information of a chart4 unmodified lines367 $ helm s[tab]368 search (search for a keyword in charts) show (show information of a chart) status (displays the status of the named release)369 ```370 368-Cobra 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:371+Cobra 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 ```go373 ValidArgsFunction: 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 lines408 Cobra provides two versions for bash completion. The original bash completion (which started it all!) can be used by calling409 `GenBashCompletion()` or `GenBashCompletionFile()`.410 411 A 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 completion414+solution described in this document.415 Unless your program already uses the legacy dynamic completion solution, it is recommended that you use the bash416 completion 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