Closed gforcada closed 8 years ago
Looking at argparse I see that this could be achieved with nargs='*'
i.e.:
myapp --filter some-value some-other-value
In fact, you can do it with @arg
decorator:
@argh.arg('--patterns', nargs='*')
def cmd(patterns=None):
distros = ('abc', 'xyz')
return [d for d in distros if not patterns
or any(p in d for p in patterns)]
I don't see how it can be made easier. OTOH, I do recognize the lack of documentation.
Please reopen the issue if you have any better idea. Thanks!
I'm building a command line interface and would like to be able to repeat the same command and get that collected as a list, i.e.:
myapp --filter some-value --filter some-other-value
By default if the
filter
parameter is a string you only get the last value (in the example abovesome-other-value
), if it is defined as a list then you get again the same value but as a list :-/