pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.42k stars 370 forks source link

Add support for argument choices, like argparse #930

Open kisielk opened 1 year ago

kisielk commented 1 year ago

I have a ton of use cases where it would be beneficial to be able to define the valid choices for an option, much like argparse can:

https://docs.python.org/3/library/argparse.html#choices

My suggestion would be to add this as a map to the task decorator similiar to how help works now:

@task(choices={'foo': ['a', 'b', 'c']})
def mytask(c, foo):
    # stuff