go-flags icon indicating copy to clipboard operation
go-flags copied to clipboard

add --no-flag for --flag boolean flags

Open cppforlife opened this issue 8 years ago • 2 comments

may be add a configuration negavtive:"true" to the DSL to indicate which flags should receive --no-* automatically? wdyt?

cppforlife avatar Aug 29 '16 23:08 cppforlife

The design of boolean flags has been that you only ever can turn them enabled, not disabled. See #80 and #175 for previous discussion.

jessevdk avatar Sep 03 '16 13:09 jessevdk

I'm trying to use the ini support as a "default" file, where we enable a boolean flag, and need an easy way to disable it from the CLI.

Using a custom Bool type adds some overhead -- now the user always has to specify --flagname=true rather than just --flagname. The ideal option would be using --no-flagname, but this is not easy to do outside of the library. We'd have to create a second flag, post-process the struct to flip flagname to false, etc.

Having a configuration option in Options to automatically register --no-flagname for booleans would be ideal, does that seem OK to you?

prashantv avatar Feb 13 '17 23:02 prashantv