Skip to content
Myr

Update shell_completions.md (#1907)

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

align documentation with the code : completions.go:452

authored by Ggg6542 · committed by GitHub · parent 8b8ee87 · Browse files · 1 file+1 added−10 removed
This commit

State

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

Diff stats

1 file+1 added−10 removed

  • other:+1 added−10 removed

1 file+1 added−10 removed

modified:shell_completions.md+1 added-10 removed
160 unmodified lines
161 ArgAliases: argAliases162}163```164165The aliases are not shown to the user on tab completion, but they are accepted as valid nouns by166the completion algorithm if entered manually, e.g. in:165The aliases are shown to the user on tab completion only if no completions were found within sub-commands or `ValidArgs`.166168```bash169$ kubectl get rc [tab][tab]170backend frontend database171```172173Note that without declaring `rc` as an alias, the completion algorithm would not know to show the list of174replication controllers following `rc`.175167### Dynamic completion of nouns168169In some cases it is not possible to provide a list of completions in advance. Instead, the list of completions must be determined at execution-time. In a similar fashion as for static completions, you can use the `ValidArgsFunction` field to provide a Go function that Cobra will execute when it needs the list of completion choices for the nouns of a command. Note that either `ValidArgs` or `ValidArgsFunction` can be used for a single cobra command, but not both.170Simplified code from `helm status` looks like:
402 unmodified lines