Skip to content

Commit

Permalink
Support __completeNoDesc hidden command (#1922)
Browse files Browse the repository at this point in the history
The __completeNoDesc command is used by bash to request completion
without any descriptions.  It must be properly supported for
cobra.Command.ValidArgsFunction to work with bash completion.

Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
  • Loading branch information
marckhouzam committed Nov 27, 2020
1 parent c011943 commit e132922
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/root.go
Expand Up @@ -87,8 +87,9 @@ func shouldPrependRelease(cmd *cobra.Command, args []string) bool {
return false
}

// allow help and __complete commands.
if len(args) > 0 && (args[0] == "help" || args[0] == "__complete") {
// allow help and the two __complete commands.
if len(args) > 0 && (args[0] == "help" ||
args[0] == cobra.ShellCompRequestCmd || args[0] == cobra.ShellCompNoDescRequestCmd) {
return false
}

Expand Down

1 comment on commit e132922

@vercel
Copy link

@vercel vercel bot commented on e132922 Nov 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.