Specifying a boolean option in the form `--option true` creates confusing error, and help text does not specify that this is invalid
TL;DR
If you try to specify a boolean option like so (--auto-delete false), the command fails with a baffling error message. This is intentionally not supported, but the help text doesn't inform you of that.
Expected behavior
The error message should ideally be more helpful, and the help text should definitely let me know not to specify booleans like that in the first place (the correct form is --auto-delete=false). Flags that accept strings can be specified with a space, so without documentation saying otherwise, it's not unreasonable to assume that the same applies to boolean flags.
Observed behavior
> hcloud server create --name test-server-3 --type cpx11 --image debian-13 --start-after-create false
hcloud server create [options] --name <name> --type <server-type> --image <image>
^
hcloud: expected exactly 0 positional argument(s), but got 1
Minimal working example
No response
Log output
Additional information
This is an upstream issue, but that doesn't mean it's not also a bug in hcloud.
See https://github.com/spf13/pflag/issues/410 (I'm not sure if cobra uses the help output generated by this library directly or not)
Hey, thanks for your report! It looks like you already had a productive conversation with the upstream maintainers and a fix is on the way (https://github.com/spf13/pflag/pull/453). This is really welcome, since we already had issues with the documentation of boolean values in the past: https://github.com/hetznercloud/cli/issues/984 Since we use the help text generation from cobra, which uses pflag, the change will also carry over into the hcloud CLI. Thanks for your engagement!
Thanks for confirming that cobra directly uses the help output of pflag! I still wasn't sure about that.