spf13/cobra

How do I use multiple characters in a short parameter?

maijun-sec opened this issue · 5 comments

When I use multiple characters in a short parameter, I got the following error:
image
How can I use multiple characters in this scenario? Thanks very much!

Can you provide a command-line example of what you did?

The code I used to add arguments is as follows:
func init() { rootCmd.Flags().BoolP("use-user-include", "uui", true, "Use user include search path.") rootCmd.Flags().StringP("xxxxxxxx", "x", "test", "testargadsfa") }

And I directly debug the code in GoLand IDE, and there is no arguments.

Hi @maijun-sec ; cobra cli can accept multichar shorthand.

cobra mentions it is "Fully POSIX-compliant flags (including short & long versions)" and only allows single characters for shorthands (similar to many other GNU commands)

As @capsci mentioned, the short parameter can only be a single character, so you cannot use "uui" as the second argument to rootCmd.Flags().BoolP("use-user-include", "uui", true, "Use user include search path.")

ok. I know, thank you very much.