I am looking for a way to parse the following commandline syntax using the argparse module in python3:
myapp.py [folder] [[from] to]
Meaning: The user may optionally define a folder, which defaults to cwd. Additionally the user may pass up to two integers. If only one number is given, it should be stored in the to variable. This is similar to the syntax of the python builtin range().
e.g.:
myapp.py folder
myapp.py 10
myapp.py 5 10
myapp.py folder 5 10
myapp.py folder 10
Is that possible? If so, how?
myapp folderandmyapp 10? As far as I see it, you don't have much of a choice other than to post-process the returned namespace -- At which point, you might as well just processsys.argv