kong icon indicating copy to clipboard operation
kong copied to clipboard

Xor is ignored with positional arguments

Open mitar opened this issue 3 years ago • 4 comments
trafficstars

I would like to do something like:

run --defaults

or:

run foo bar

but prevent:

run --defaults foo bar

It seems xor for positional arguments (flag with arg:"") does not do anything: there is no error if both are provided.

mitar avatar Dec 22 '21 00:12 mitar

That's correct, xor is currently only applicable to flags. Seems reasonable though.

alecthomas avatar Dec 22 '21 00:12 alecthomas

I'm trying to add a --version flag, with that flag no positional arguments are required what would be the correct way of doing that if xor ignores positionals?

everdrone avatar Jun 23 '22 09:06 everdrone

Use VersionFlag.

mitar avatar Jun 23 '22 09:06 mitar

I have a need for this as well.

@alecthomas, you said "Seems reasonable though", but that was a while ago. Before I start diving into this, are you still open to a PR for to include positional arguments in xor?

WillAbides avatar Nov 15 '23 18:11 WillAbides