mpeterv / argparse

Feature-rich command line parser for Lua
MIT License
260 stars 45 forks source link

option with specific choices list #10

Open Veratil opened 7 years ago

Veratil commented 7 years ago

I don't see any mention of this in the docs, but it would be nice to mimic the choices parameter as seen in the python argparse module (https://docs.python.org/dev/library/argparse.html#choices).

mpeterv commented 7 years ago

This is a good idea. Python's argparse accepts any value that has in operator as choices parameter, but in Lua it makes sense to support only arrays, at first at least. I'll try to implement this when I have time, in the meantime pull requests are welcome.

nwf commented 2 years ago

FWIW, this is implemented in the luarocks branch of this repository, at https://github.com/luarocks/argparse, in https://github.com/luarocks/argparse/pull/3/commits/dcd5162710fcc7f354ffa5eaed574e0cd6f03d06 in particular.