mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
feat(comp): Move to Cobra's bash completion V2
Cobra's bash completion V2 has the following benefits: - aligned with the completion logic for the other shells - provides completion descriptions as for the other shells - uses a 300-line shell script (versus 4K lines for V1) Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
This commit is contained in:
parent
c6dfb490ab
commit
efe2638f87
1 changed files with 7 additions and 7 deletions
|
|
@ -98,16 +98,16 @@ func newCompletionCmd(out io.Writer) *cobra.Command {
|
|||
}
|
||||
|
||||
bash := &cobra.Command{
|
||||
Use: "bash",
|
||||
Short: "generate autocompletion script for bash",
|
||||
Long: bashCompDesc,
|
||||
Args: require.NoArgs,
|
||||
DisableFlagsInUseLine: true,
|
||||
ValidArgsFunction: noCompletions,
|
||||
Use: "bash",
|
||||
Short: "generate autocompletion script for bash",
|
||||
Long: bashCompDesc,
|
||||
Args: require.NoArgs,
|
||||
ValidArgsFunction: noCompletions,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runCompletionBash(out, cmd)
|
||||
},
|
||||
}
|
||||
bash.Flags().BoolVar(&disableCompDescriptions, noDescFlagName, false, noDescFlagText)
|
||||
|
||||
zsh := &cobra.Command{
|
||||
Use: "zsh",
|
||||
|
|
@ -151,7 +151,7 @@ func newCompletionCmd(out io.Writer) *cobra.Command {
|
|||
}
|
||||
|
||||
func runCompletionBash(out io.Writer, cmd *cobra.Command) error {
|
||||
err := cmd.Root().GenBashCompletion(out)
|
||||
err := cmd.Root().GenBashCompletionV2(out, !disableCompDescriptions)
|
||||
|
||||
// In case the user renamed the helm binary (e.g., to be able to run
|
||||
// both helm2 and helm3), we hook the new binary name to the completion function
|
||||
|
|
|
|||
Loading…
Reference in a new issue