Skip to content

Commit

Permalink
feat(comp): Move to Cobra's bash completion V2
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
marckhouzam committed Aug 2, 2021
1 parent c6dfb49 commit efe2638
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/helm/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit efe2638

Please sign in to comment.