c-blake / cligen

Nim library to infer/generate command-line-interfaces / option / argument parsing; Docs at
https://c-blake.github.io/cligen/
ISC License
501 stars 23 forks source link

Support -no- style boolean negation #151

Closed paradox460 closed 4 years ago

paradox460 commented 4 years ago

A common pattern among some other CLI tools is the use of -no- style negation for boolean fields that are default true.

Example: git

git merge -ff <whatever>
git merge -no-ff <whatever>

This would be a nice alternative to having to write --boolfield=false

I realize that the default syntax has a true field automatically negate, and so in my tools I've adjusted the names accordingly

c-blake commented 4 years ago

You may be unaware, but there are really very short aliases for bool values. Just 't' and 'f' work, for example (or '[yn]' see --help-syntax). --no-foo is actually one character longer than --foo=f or --foo f or -f:f if 'f' is the short for "foo".

Tools I know that do this are not even of the single-dash short/double-dash long variety but more single-dash-long like gcc. There the amount of typing may be the same, but there is already a more (IMO) jarring syntax departure afoot. There's only so much coherence in the broader CLI universe. I think super short bool values are the best we can/should do here.

Thanks for the brainstorming, though.

c-blake commented 4 years ago

There is also some prior discussion about relevant behaviors here: https://github.com/c-blake/cligen/issues/16