casperdcl / argopt

convert docopt to argparse
https://pypi.python.org/pypi/argopt
Other
21 stars 2 forks source link

Support choices #12

Open casperdcl opened 4 years ago

casperdcl commented 4 years ago

i.e.: add_argument(choices=...)

Maybe interface could be

--arg ARG  : choose from [default: dflt|another|third:[str]]
Freed-Wu commented 1 year ago

However, argparse allow user to use different type in choices, such as:

from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("--arg", choices = ["a", 1])

So, it may be:

--arg ARG: choose from [default: 1|a:[int:str]]

And

--arg ARG: choose from [default: 1|a:[str]]

should be recognized as

from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("--arg", choices = ["a", "1"])