alecthomas / kingpin

CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow multi-item values

opened this issue · comments

In python argparse, we can implement this: command (--flag_a FIRST_ITEM SECOND_ITEM) (--flag_a FIRST_ITEM SECOND_ITEM) --flag_b -- some free args. (through the nargs setting)

This is different from repeating the same flag n times.
Here a flag can have a list of values rather than a single value AND also be repeatable.

How does it differentiate between --flag_a <flag-value> <flag-value> and --flag_a <flag-value> <positional-arg-value> unambiguously?

It doesn't, unfortunately. If you pass --flag_a VALUE POSITIONAL it will treat POSITIONAL as the second VALUE. It will only detect the error if you pass --flag_a VALUE -- POSITIONAL or --flag_a VALUE --other_flag

Ok, yeah that's why I didn't implement this in the first place. I'd prefer determinism over ambiguity, though I realise it's slightly more annoying.