If you've ever struggled with argparse--and let's be honest, I know you have--then you might be interested in docopt. docopt is a simpler way to write an argument parser, by not writing the argument parser at all.
...] Process some integers. positional arguments: N an integer for the accumulator optional arguments: -h, --help show this help message and exit --sum sum the integers (default: find the max)
Process some integers. Arguments: N an integer for the accumulator Options: -h, --help show this help message and exit --version show version information --sum sum the integers
boom get <key> boom add [-f|--force] <key> [<contents>] boom delete [-f|--force] <key> boom find <term> Commands: add <key> <contents> Adds <key> with value <contents> get <key> Displays the value of <key> delete <key> Deletes <key> and its value find <term> Find keys matching <term> Options: -h, --help Print this message --version Print version information -f, --force Don't confirm the action
boom <key> boom get <key> boom add [-f|--force] <key> [<contents>] boom delete [-f|--force] <key> boom find <term> Commands: add <key> <contents> Adds <key> with value <contents> get <key> Displays the value of <key> delete <key> Deletes <key> and its value find <term> Find keys matching <term> Options: -h, --help Print this message --version Print version information -f, --force Don't confirm the action """
boom <key> boom get <key> boom add [-f|--force] <key> [<contents>] boom delete [-f|--force] <key> boom find <term> Commands: add <key> <contents> Adds <key> with value <contents> get <key> Displays the value of <key> delete <key> Deletes <key> and its value find <term> Find keys matching <term> Options: -h, --help Print this message --version Print version information -f, --force Don't confirm the action """ from docopt import docopt
<key> boom get <key> boom add [-f|--force] <key> [<contents>] boom delete [-f|--force] <key> boom find <term> Commands: add <key> <contents> Adds <key> with value <contents> get <key> Displays the value of <key> delete <key> Deletes <key> and its value find <term> Find keys matching <term> Options: -h, --help Print this message --version Print version information -f, --force Don't confirm the action """ from docopt import docopt if __name__ == '__main__': arguments = docopt(__doc__, version='boom.py 1.0') print(arguments) BOOM.PY
boom <key> boom get <key> boom add [-f|--force] <key> [<contents>] boom delete [-f|--force] <key> boom find <term> Commands: add <key> <contents> Adds <key> with value <contents> get <key> Displays the value of <key> delete <key> Deletes <key> and its value find <term> Find keys matching <term> Options: -h, --help Print this message --version Print version information -f, --force Don't confirm the action """ from docopt import docopt if __name__ == '__main__': arguments = docopt(__doc__, version='boom.py 1.0') print(arguments)