shflags
shflags copied to clipboard
Enhancement: Add the ability to have a flag without the negate option
Sometimes it's useful to have a boolean flag that doesn't have a negate option.
For example:
DEFINE_boolean 'force' false 'force overwriting' 'f'
It's not needed to have a --noforce for this option as omitting the flag has
the same result.
We can add an exclamation mark at the end of the flag name to indicate there is
no negate option for this flag.
In the above eample the new define statement would be:
DEFINE_boolean 'force!' false 'force overwriting' 'f'
The patch already has this for the build in help flag.
DEFINE_boolean 'help!' false 'show this help' 'h'
Original issue reported on code.google.com by [email protected] on 9 Jan 2013 at 3:24
Attachments:
If accepted the calls to the two functions:
_flags_underscoreName()
_flags_removeExclamationName()
could probably be replaced by a new function like
_flags_cleanupName
Which in itself would either call the above two functions or would do what the
above two functions do.
Original comment by [email protected] on 9 Jan 2013 at 3:27
Hmmm, need some more thought into this. Test for nohelp fails, as the option
nohelp isn't generated with the above patch. There is also another small bug in
the patch, the exclamation mark isn't stripped during the genOptString function
(I know how to fix, just seemed redundant to this because of the nohelp fails)
Original comment by [email protected] on 10 Jan 2013 at 3:20
I guess the test for the nohelp is correct to fail, as there is no option
nohelp anymore. If this would be implemented the test would need to change, or
the test is redundant and can be removed.
Original comment by [email protected] on 10 Jan 2013 at 2:31
Well this a better patch, I uses built-in functionality if able to.
Original comment by [email protected] on 21 Jan 2013 at 7:24
Attachments:
And we just keep fixing it :)
Original comment by [email protected] on 22 Jan 2013 at 7:21
Attachments:
See Pull Request #34