args icon indicating copy to clipboard operation
args copied to clipboard

Support overriding the default negated name of a boolean flag.

Open wibling opened this issue 9 years ago • 3 comments

It would be great to be able to use the args package in contexts where the naming convetion for negated flags are different which requires overriding the default negated flag name (--no-).

This could e.g. be done by adding an optional negatedName parameter to the addFlag method.

wibling avatar Jun 02 '15 09:06 wibling

Could you give an example? Is it still a prefix, or does it replace the whole name?

seaneagan avatar Jun 02 '15 13:06 seaneagan

I was thinking it should just replace the entire negated name.

Something like

parser.addFlag('fast', negatedName: 'slow')

which results in the --slow flags being the opposite of the --fast which in some cases are better than the default --no-fast. This would also allow changing the prefix, by e.g.

parser.addFlag('foo', negatedName: 'nofoo');

giving --nofoo instead of --no-foo.

wibling avatar Jun 02 '15 13:06 wibling

I just took a look at the code and the way it is structured today seems like it would be much simpler to support a new prefix that overriding the full name.

Solving the second use case above by supporting a new negated prefix would be great too. Completely overriding negated flag names could come as an additional improvement later.

wibling avatar Jun 03 '15 08:06 wibling