Skip to content

Commit 07861c8

Browse files
authored
Fix documentation (#1434)
Signed-off-by: Marc Khouzam <[email protected]>
1 parent 5738d6b commit 07861c8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

shell_completions.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,10 @@ cmd.RegisterFlagCompletionFunc(flagName, func(cmd *cobra.Command, args []string,
352352
```
353353
### Descriptions for completions
354354
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 shell
356+
(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:
356359
```
357360
$ helm s[tab]
358361
search -- search for a keyword in charts
@@ -365,7 +368,7 @@ $ helm s[tab]
365368
search (search for a keyword in charts) show (show information of a chart) status (displays the status of the named release)
366369
```
367370
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:
369372
```go
370373
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
371374
return []string{"harbor\tAn image registry", "thanos\tLong-term metrics"}, cobra.ShellCompDirectiveNoFileComp
@@ -406,8 +409,9 @@ Cobra provides two versions for bash completion. The original bash completion (
406409
`GenBashCompletion()` or `GenBashCompletionFile()`.
407410

408411
A new V2 bash completion version is also available. This version can be used by calling `GenBashCompletionV2()` or
409-
`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 completion
413+
(see [Bash Completions](bash_completions.md)) but instead works only with the Go dynamic completion
414+
solution described in this document.
411415
Unless your program already uses the legacy dynamic completion solution, it is recommended that you use the bash
412416
completion V2 solution which provides the following extra features:
413417
- Supports completion descriptions (like the other shells)

0 commit comments

Comments
 (0)