You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a feature request for the "no" prefix modifier where you can prepend 'no' to a flag, and it inverts its value.
For example, imagine a --verbose flag that enables debugging chatter. A user can explicitly use --noverbose to do the opposite action that disables the debugging chatter.
I've used this feature in a some other argument parsing libraries for other languages, so I know the feature has been in the wild. (I'm currently trying to port a Perl utility that uses the standard GetOpt::Long which has the feature.)
I've tried emulating this with 2 flags in a mutex, but it is clumsy. The first problem is you end up with two separate flags with separate variables that still don't know that they need to be inversions of one another. So they can easily be out of sync. In the base case, where neither switch is set, then both are nil. If I set defaults to each, then when the user sets the non-default way, then both flags result in being the same value (since they don't have a direct relationship). In either case, this requires me to write extra setup code to check all the permutations and explicitly set both counterpart values in case I'm inconsistent about which variable I use to compare logic later in my app.
The second problem is you need to write two separate description entries, which can be redundant and clutter things. It seems like there should be a way to combine the entries in some ways. (The switch itself can be abbreviated as --[no]verbose.)
Thank you
The text was updated successfully, but these errors were encountered:
This is a feature request for the "no" prefix modifier where you can prepend 'no' to a flag, and it inverts its value.
For example, imagine a --verbose flag that enables debugging chatter. A user can explicitly use --noverbose to do the opposite action that disables the debugging chatter.
I've used this feature in a some other argument parsing libraries for other languages, so I know the feature has been in the wild. (I'm currently trying to port a Perl utility that uses the standard GetOpt::Long which has the feature.)
I've tried emulating this with 2 flags in a mutex, but it is clumsy. The first problem is you end up with two separate flags with separate variables that still don't know that they need to be inversions of one another. So they can easily be out of sync. In the base case, where neither switch is set, then both are nil. If I set defaults to each, then when the user sets the non-default way, then both flags result in being the same value (since they don't have a direct relationship). In either case, this requires me to write extra setup code to check all the permutations and explicitly set both counterpart values in case I'm inconsistent about which variable I use to compare logic later in my app.
The second problem is you need to write two separate description entries, which can be redundant and clutter things. It seems like there should be a way to combine the entries in some ways. (The switch itself can be abbreviated as --[no]verbose.)
Thank you
The text was updated successfully, but these errors were encountered: