Please allow booleans to be set false with no-
prefix
#958
Labels
area/flags-args
Changes to functionality around command line flags and args
no-
prefix
#958
@eparis wrote
This behavior is unlike any other tool I have encountered. The behavior I am used to and consider "normal" for Unix commands, for boolean options, is:
-b
, the option toggles the default value when present. There is generally no way to affirmatively assert the default value with a short flag, though some commands allow it with the same option in the other case, e.g.-B
--bool
, the named option sets the flag true, and the option with ano-
prefix sets the flag false, e.g.--no-bool
. The "usage" for such a flag would be something likeSee, for just one example,
git-merge
. (Truthfully, most commands are written so there is just a default value and a flag which toggles the default, with the flag being prefixed withno-
when it makes for better style, such as--no-undefined Do not allow undefined values
. However, when configuration can come from many sources, a command-line option re-asserting default behavior and overriding the other configuration sources is a valuable feature.)The current state where a flag with an argument is written
-f file
but a boolean cannot be written-b true
is painfully inconsistent as well as awkward, to the point where other options parsers simply do not allow boolean short flags to take arguments. I suggest that instead you automatically create--bool
and--no-bool
options for all booleans with long forms and if possible provide some kind of warning against creating a short option that has no effect.Note: I have no problem allowing
--bool=false
and I support continuing to allow that as it can make scripting easier. On the other hand,--no-bool=true
is just plain confusing and should not be allowed.The text was updated successfully, but these errors were encountered: