Closed r10r closed 2 months ago
Cobra supports multiple single letter flags strung together e.g., prog -abcd
is equivalent to prog -a -b -c -d
.
If you also have a long flag --abcd
there would be ambiguity without the double --
@marckhouzam thanks for the explanation. i’ll see if I can add this to the FAQ
Hi there,
I'm a new cobra user who has used the standard libraries flag package in a lot of single command binaries. When implementing my first application with cobra I stumbled upon the flag parsing.
Calling the application with a single dash will result in unexpected behaviour.
Using the double dash gives the expected result
To me it happens quite often that I miss a dash when typing a long option without shell completion. The flag parsing from the library flag package is quite nice here and does not distinguish between a a single or a double dash.
See also https://pkg.go.dev/flag#hdr-Command_line_flag_syntax
Is it possible to introduce a setting in cobra to make the flag parsing (optionally) compliant with the flag package of the standard library ?