i trying use docopt python code. need set specific values parameter. usage below:
""" usage: test.py --list=(all|available) options: list choice list devices (all / available) """
i've tried run as: python test.py --list=all
doesn't accept value , displays docopt string .
i want value of list parameter either 'all' or 'available'. there way can achieved?
here's example achieve want:
test.py:
""" usage: test.py list (all|available) options: -h --help show screen. --version show version. list choice list devices (all / available) """ docopt import docopt def list_devices(all_devices=true): if all_devices: print("listing devices...") else: print("listing available devices...") if __name__ == '__main__': arguments = docopt(__doc__, version='test 1.0') if arguments["list"]: list_devices(arguments["all"])
with script run statements like:
python test.py list
or:
python test.py list available
Comments
Post a Comment