From 75c63c0f2a86ef710522b7f2c88e47d39c79bffc Mon Sep 17 00:00:00 2001 From: Shihta Kuan Date: Mon, 30 Jan 2023 11:37:53 +0800 Subject: [PATCH 1/2] add a hint about the disabling completion descriptions to document --- shell_completions.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shell_completions.md b/shell_completions.md index 286c2525b..4cee736ad 100644 --- a/shell_completions.md +++ b/shell_completions.md @@ -173,6 +173,21 @@ backend frontend database Note that without declaring `rc` as an alias, the completion algorithm would not know to show the list of replication controllers following `rc`. +#### Disable completion descriptions + +If you don't want to show descriptions in the completion, you can add `--no-descriptions` to disable it, like: + +```bash +$ source <(helm completion bash) +$ helm completion [tab][tab] +bash (generate autocompletion script for bash) powershell (generate autocompletion script for powershell) +fish (generate autocompletion script for fish) zsh (generate autocompletion script for zsh) + +$ source <(helm completion bash --no-descriptions) +$ helm completion [tab][tab] +bash fish powershell zsh +``` + ### Dynamic completion of nouns In 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. From 4fa652d2985662affbf6f164baa0878a80444cb5 Mon Sep 17 00:00:00 2001 From: Shihta Kuan Date: Mon, 30 Jan 2023 23:27:09 +0800 Subject: [PATCH 2/2] move to another section --- shell_completions.md | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/shell_completions.md b/shell_completions.md index 4cee736ad..f3285e310 100644 --- a/shell_completions.md +++ b/shell_completions.md @@ -173,21 +173,6 @@ backend frontend database Note that without declaring `rc` as an alias, the completion algorithm would not know to show the list of replication controllers following `rc`. -#### Disable completion descriptions - -If you don't want to show descriptions in the completion, you can add `--no-descriptions` to disable it, like: - -```bash -$ source <(helm completion bash) -$ helm completion [tab][tab] -bash (generate autocompletion script for bash) powershell (generate autocompletion script for powershell) -fish (generate autocompletion script for fish) zsh (generate autocompletion script for zsh) - -$ source <(helm completion bash --no-descriptions) -$ helm completion [tab][tab] -bash fish powershell zsh -``` - ### Dynamic completion of nouns In 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. @@ -400,6 +385,19 @@ or ```go ValidArgs: []string{"bash\tCompletions for bash", "zsh\tCompletions for zsh"} ``` + +If you don't want to show descriptions in the completions, you can add `--no-descriptions` to the default `completion` command to disable them, like: + +```bash +$ source <(helm completion bash) +$ helm completion [tab][tab] +bash (generate autocompletion script for bash) powershell (generate autocompletion script for powershell) +fish (generate autocompletion script for fish) zsh (generate autocompletion script for zsh) + +$ source <(helm completion bash --no-descriptions) +$ helm completion [tab][tab] +bash fish powershell zsh +``` ## Bash completions ### Dependencies