cobra
cobra copied to clipboard
Description in completion in double (not sure it's a Cobra issue)
First, thanks a lot to develop this package. It makes all our work so smooth :)
Now, I've got a little problem.
I generate the completion command this way:
func generateCompletionCommand(name string) *cobra.Command {
bashV1 := false
cmd := &cobra.Command{
Use: "completion",
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Short: "Generates completion scripts",
Long: fmt.Sprintf(completionHelp, name),
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
cmd.Help()
return
}
switch args[0] {
case "bash":
// get the bash version
if cmd.Flags().Changed("bash-v1") {
cmd.Root().GenBashCompletion(os.Stdout)
return
}
cmd.Root().GenBashCompletionV2(os.Stdout, true)
case "zsh":
cmd.Root().GenZshCompletion(os.Stdout)
case "fish":
cmd.Root().GenFishCompletion(os.Stdout, true)
case "powershell":
cmd.Root().GenPowerShellCompletion(os.Stdout)
}
},
}
// add a flag to force bash completion v1
cmd.Flags().Bool("bash-v1", bashV1, "Force bash completion v1")
return cmd
}
No need to use \t
to get completion and it works... excepting that the descriptions are display in double. The left column is OK, while the second breaks the shell command.
See this screencast:
I don't understand why this breaks.
Note:
- bash v5 + bash-completion
- oh-my-posh (no special configuration)
- Fedora 38
- kitty-terminal
- menu-complete option in inputrc
What version of Cobra are you using @metal3d ? This looks like #1508 which I thought we'd fixed...
It's the 1.7.0 (latest release).
can you remove the menu-complete option in inputrc and see if things work properly that way?
@metal3d Have you been able to resolve your issue?
Sorry, a lot of troubles to manage for weeks... I'll try as soon as I can. I put this in my TODO list for the next days.