pflag icon indicating copy to clipboard operation
pflag copied to clipboard

Support Boolean flags with only `NoOptDefVal`, no `--foo=true` syntax.

Open sixolet opened this issue 6 years ago • 6 comments

Rationale: the flag --no-shave-yaks alone is pretty clear: I don't want the program to shave any yaks. However --no-shave-yaks=true and --no-shave-yaks=false both get me confused with exactly how much negation I'm applying to all this yak-shaving.

sixolet avatar Aug 08 '19 17:08 sixolet

I am in favor of pairing --no-shave-yaks with --shave-yaks and disallowing --no-shave-yaks=true and --no-shave-yaks=false as overly confusing.

However, thinking about the various use cases where a command might be scripted, if we enforce/automatically create --no-shave-yaks and --shave-yaks in pairs, then I would like to keep the ability to set --shave-yaks=true and --shave-yaks=false. This would allow one to propagate or group a variable setting without having to have a more complicated conditional substitution. For example:

export GROOMING=false

command --shave-yaks=${GROOMING}

A similar case (easier scripting) could be made for allowing --no-shave-yaks=false, but I agree it is too confusing.

Nuru avatar Oct 03 '19 22:10 Nuru

What is the status of this issue? I would love to have this as well.

feluelle avatar Nov 23 '22 06:11 feluelle