{ "info": { "author": "Austin Bingham", "author_email": "austin@sixty-north.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8" ], "description": "[![Build Status](https://travis-ci.org/abingham/docopt-subcommands.png?branch=master)](https://travis-ci.org/abingham/docopt-subcommands)\n\n# docopt-subcommands\n\nA simple implementation of subcommands for docopt.\n\n`docopt-subcommands` allows you to create subcommand-based programs\nusing [docopt](https://github.com/docopt/docopt). A subcommand-based program is\none in which the main program uses a \"subcommand\" argument to tell it what to\ndo.\n\nThe classic example of such a program is [git](https://git-scm.com/). The `git`\ncommand with no arguments doesn't do much of anything. Instead, it's the first\nargument to `git` - the *subcommand* - that tells it what to actually do. For\nexample:\n\n```\ngit log\n```\n\nwill give you the log for your repository. Likewise:\n\n```\ngit rebase\n```\n\nis the subcommand for rebasing.\n\n`docopt-subcommands` is here to help you create similar kinds of command-line\ntools with `docopt`'.\n\n## Quickstart\n\nThe basic idea behind `docopt-subcommands` is simple:\n\n 1. You provide a separate *handler function* for each subcommand.\n 2. The docstring for each handler function defines the docopt definition for\n that subcommand.\n 3. You register your handler functions with the names of the subcommands which\n will invoke them.\n 4. You provide a program name and (optionally) a top-level documentation string.\n\nThen `docopt-subcommands` does the work of stitching everything together into a\nsubcommand-driven program. Here's how it looks (from the included\n`exampels/basic_example.py`):\n\n```python\n# Basic, most common usage of docopt_subcommands\n\nimport docopt_subcommands as dsc\n\n\n# 1. Use the `command` decorator to add subcommands functions.\n@dsc.command()\ndef foo_handler(precommand_args, args):\n \"\"\"usage: {program} foo \n\n Apply foo to a name.\n \"\"\"\n print(\"Foo, {}\".format(args['']))\n\n\n@dsc.command()\ndef bar_handler(precommand, args):\n \"\"\"usage: {program} bar \n\n Apply bar to a name.\n \"\"\"\n print(\"Bar, {}\".format(args['']))\n\n\n# 2. Pass a program name and version string to `main` to run a program with the\n# subcommands you defined with the decorators above.\ndsc.main(program='docopt-subcommand-example')\n```\n\nIf you run this program at the command line you'll see that you have a nice,\nsubcommand-based CLI program:\n\n```shell\n$ python basic_example.py\nUsage: docopt-subcommand-example [options] [ ...]\n$ python basic_example.py -h\ndocopt-subcommand-example\n\nUsage: docopt-subcommand-example [options] [ ...]\n\nOptions:\n -h --help Show this screen.\n\nAvailable commands:\n bar\n foo\n\nSee 'docopt-subcommand-example help ' for help on specific commands.\n\n$ python basic_example.py foo\nusage: docopt-subcommand-example foo \n\n$ python basic_example.py foo -h\nusage: docopt-subcommand-example foo \n\nApply foo to a name.\n\n$ python basic_example.py foo Bubba\nFoo, Bubba\n```\n\nFor more examples, see the `examples` directory.\n\n## Common options\n\nMany subcommand-based programs have a set of options that are common to all commands. A common example is `--verbose`\nwhich causes the program to print more information not matter which command is executed. With `docopt_subcommands` you specify these common options in the top-level docstring like this::\n\n TOP_LEVEL_DOC = \"\"\"{program}\n\n Usage: {program} [options] [ ...]\n\n Options:\n -h --help Show this screen\n --verbose Use verbose output\n\n Available commands:\n {available_commands}\n \"\"\"\n\nWith this docstring, you can provide the `--verbose` flag for any subcommand. Critically, **common options must be provided before the subcommand name.** So if `bar` was a subcommand in your program, you would write::\n\n my_program --verbose bar\n\nbut not::\n\n my_program bar --verbose\n\n`docopt_subcommands` parses the complete command line in two passes. The first pass parses it with the top-level\ndocstring while the second pass uses the docstring for the specific command and only parses the part of the command line\nafter the common options. It then provides both of the parsed dicts to the subcommand handler: the first argument to the\nhandler is the result of the first pass, and the second argument is the result of the second pass.\n\nWith this system, you can then use a single set of code to do \"common configuration\" for you program. For example,\nhere's how a handler might look:\n\n.. code-block:: python\n\n @dsc.command()\n def bar_handler(precommand_args, args):\n \"\"\"usage: {program} bar \n\n Apply bar to a name.\n \"\"\"\n handle_common_option(precommand_args)\n name = args['']\n print('Bar {}'.format(name))\n\n## Advanced usage\n\nFor most users the basic usage described in \"Quickstart\" should be all you need,\nbut some users will need more control of `docopt_subcommands`. The\n`docopt_subcommands.main()` that we used earlier is really just a convenience\nlayer on top of the real workhorse, `docopt_subcommands.Subcommands`. You can\ninstantiate this class directly, bypassing `main()`, and interact with it as you\nneed before actually invoke command-line processing.\n\nFor the most part, the arguments to the `Subcommands` initializer are very\nsimilar to those to `main()`. This reflects the fact that `main()` really just\ninstantiates a `Subcommands` instance (if you don't provide one), populates it\nwith commands, and calls it with the command line arguments. You can do all of\nthese steps yourself if you need to.\n\nAs an example, here's what the basic example above looks like if you construct a\n`Subcommands` instance directly.:\n\n```python\nimport docopt_subcommands as dsc\nimport sys\n\nsc = dsc.Subcommands(program='docopt-subcommand-example')\n\n@sc.command('foo')\ndef foo_handler(args):\n \"\"\"usage: {program} {command} \n\n Apply foo to a name.\n \"\"\"\n print(\"Foo, {}\".format(args['']))\n\n\n@sc.command('bar')\ndef bar_handler(args):\n \"\"\"usage: {program} {command} \n\n Apply bar to a name.\n \"\"\"\n print(\"Bar, {}\".format(args['']))\n\nsc(sys.argv[1:])\n```\n\nAs you can see, it's not substantially different from the basic example.\n`main()` primarily just adds a layer of convenience - mostly by choosing\nreasonable default values for some things - that you lose with this approach.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/abingham/docopt-subcommands", "keywords": "command-line docopt", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "docopt-subcommands", "package_url": "https://pypi.org/project/docopt-subcommands/", "platform": "", "project_url": "https://pypi.org/project/docopt-subcommands/", "project_urls": { "Homepage": "https://github.com/abingham/docopt-subcommands" }, "release_url": "https://pypi.org/project/docopt-subcommands/4.0.0/", "requires_dist": [ "docopt", "twine ; extra == 'dev'", "wheel ; extra == 'dev'", "hypothesis (>=1.11) ; extra == 'test'", "pytest (>=3.0.7) ; extra == 'test'" ], "requires_python": "", "summary": "create subcommand-based CLI programs with docopt", "version": "4.0.0" }, "last_serial": 5437835, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "e8fa8b19c8ddc4864e045d480700d68a", "sha256": "db4bd8313c8db6b8fff30a7a0d58f51ceabe6fa15000cda05701971ec6d5d2c8" }, "downloads": -1, "filename": "docopt_subcommands-1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e8fa8b19c8ddc4864e045d480700d68a", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6788, "upload_time": "2017-03-25T08:44:24", "url": "https://files.pythonhosted.org/packages/21/17/4082f5e081594bce549aeb7deebb73204784d899b2ca42be0414d93bcd49/docopt_subcommands-1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a8caab15d57e54f5c0d597a992895f71", "sha256": "1ff9532244c5266632d74bf84f6bf42f2f9671750950bb4f66707b035cca79c2" }, "downloads": -1, "filename": "docopt_subcommands-1.0.tar.gz", "has_sig": false, "md5_digest": "a8caab15d57e54f5c0d597a992895f71", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4201, "upload_time": "2017-03-25T14:27:36", "url": "https://files.pythonhosted.org/packages/90/a6/a018df0bea5433e226868b6e7706b1017abdd5d8dd5b22da1782d9d03baa/docopt_subcommands-1.0.tar.gz" } ], "2.0": [ { "comment_text": "", "digests": { "md5": "569bdadabb4046f11089981cf9a55aaa", "sha256": "575a709ae215c7d80dc67dbc1c50a5f2e094ec4932909722385b51425d54d5f4" }, "downloads": -1, "filename": "docopt_subcommands-2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "569bdadabb4046f11089981cf9a55aaa", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 6911, "upload_time": "2017-03-25T15:03:33", "url": "https://files.pythonhosted.org/packages/6c/a5/fe9b4c862a637f2693531a2bd08725214d3ee56d9aa50b5a2a69dc98d5ff/docopt_subcommands-2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e660aaa7b90622f875a17a205522df4e", "sha256": "f8000c51a656cc4ec7ca73914e44b6d2b114ed95d4386f0e5085290119b274ef" }, "downloads": -1, "filename": "docopt_subcommands-2.0.tar.gz", "has_sig": false, "md5_digest": "e660aaa7b90622f875a17a205522df4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4279, "upload_time": "2017-03-25T15:03:30", "url": "https://files.pythonhosted.org/packages/63/19/0b1e321e3e261f92875ae7fd337fd015e5255f61bf79a6cad63b62f3035e/docopt_subcommands-2.0.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "01f5387919cbe9d029000912e9d391ec", "sha256": "c25bacecb8a63d34f874e359c0e984f24c281133b8be456fff371273eb0c0066" }, "downloads": -1, "filename": "docopt_subcommands-2.1.1-py2-none-any.whl", "has_sig": false, "md5_digest": "01f5387919cbe9d029000912e9d391ec", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 7146, "upload_time": "2017-03-27T07:04:54", "url": "https://files.pythonhosted.org/packages/84/0c/db7e4ee75a3dbaae51bb342372903a9e8961336196259cea76997a01828a/docopt_subcommands-2.1.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0e941f94b9d69aff2fae1f960ad545a4", "sha256": "8ee902e6ed05a017f179efea101a57c2fecd17d2aa71f1841f621ecfb13aba18" }, "downloads": -1, "filename": "docopt_subcommands-2.1.1.tar.gz", "has_sig": false, "md5_digest": "0e941f94b9d69aff2fae1f960ad545a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5195, "upload_time": "2017-03-27T07:04:56", "url": "https://files.pythonhosted.org/packages/8a/f3/f7fc6f1c57b756fa7d566e921b7460645edad7080938f6678975861779be/docopt_subcommands-2.1.1.tar.gz" } ], "2.2.0": [ { "comment_text": "", "digests": { "md5": "c93cf674b324f12466bdc641243ccb9f", "sha256": "daef48969292f75c048d11785e4bfbe7418684df641ee96df94bcd0e261ea7ac" }, "downloads": -1, "filename": "docopt_subcommands-2.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c93cf674b324f12466bdc641243ccb9f", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 7290, "upload_time": "2017-03-27T08:32:14", "url": "https://files.pythonhosted.org/packages/42/73/00b8bb3b1571f7cfcad5cc4304053d3f37a029e4a56f4790d5f0d68c014f/docopt_subcommands-2.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "4b813e0f9909c6f57ed6076686c0d18e", "sha256": "c5f2f47f4dbbf4e633752765146a9880e566b2e41906b3c728461389eb04a48c" }, "downloads": -1, "filename": "docopt_subcommands-2.2.0.tar.gz", "has_sig": false, "md5_digest": "4b813e0f9909c6f57ed6076686c0d18e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5281, "upload_time": "2017-03-27T08:32:11", "url": "https://files.pythonhosted.org/packages/9e/b5/5ba220c381930aa82236ca65af6d7890d9d31f3263ec6dee0c986ac3e463/docopt_subcommands-2.2.0.tar.gz" } ], "2.3.0": [ { "comment_text": "", "digests": { "md5": "b11b7f3b3b0be21aa6abb7675748602d", "sha256": "de73a3ae454eb9c69f2cda3288d647d3b37bbf8441a63f00183b00925cabc986" }, "downloads": -1, "filename": "docopt_subcommands-2.3.0-py2.7.egg", "has_sig": false, "md5_digest": "b11b7f3b3b0be21aa6abb7675748602d", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 9828, "upload_time": "2017-07-17T12:53:51", "url": "https://files.pythonhosted.org/packages/c5/83/33a58071038f4612ae9dab58340485d15ed4ba9d19740622808fe522f7d4/docopt_subcommands-2.3.0-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "764ce44ec5916d144336465a9756b38b", "sha256": "829b81d15dece1257f47a993ae3deaa5b725be9ee9813936bed55fd795c97780" }, "downloads": -1, "filename": "docopt_subcommands-2.3.0-py3.6.egg", "has_sig": false, "md5_digest": "764ce44ec5916d144336465a9756b38b", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 9909, "upload_time": "2017-07-17T12:53:43", "url": "https://files.pythonhosted.org/packages/9c/a1/e9f905b385a06aab7cb67d876da8084633ca6de98c55acfc9dae62febc5e/docopt_subcommands-2.3.0-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "45adec49b2a1ba79619b269a4537c218", "sha256": "f7b9b97ef24995119602463a373b9e12b69665c71e3fe6feea7cbacba4361895" }, "downloads": -1, "filename": "docopt_subcommands-2.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "45adec49b2a1ba79619b269a4537c218", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 8649, "upload_time": "2017-07-18T13:01:11", "url": "https://files.pythonhosted.org/packages/51/91/e8cc7859ff376a36e48ed0c6d1f9ad98be515e2af27ba6107bb1c9eb70d3/docopt_subcommands-2.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f2a14737aaaa4c1f899807b647a8e9a1", "sha256": "9349f3908f6e5547f485456fa35d3f579c2f63386c4fa0e55930fbef4bd4c7c7" }, "downloads": -1, "filename": "docopt_subcommands-2.3.0.tar.gz", "has_sig": false, "md5_digest": "f2a14737aaaa4c1f899807b647a8e9a1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7214, "upload_time": "2017-09-23T07:14:44", "url": "https://files.pythonhosted.org/packages/b2/b9/b4bc08f7d462fbf7616ccc91c7df6130276e4abf6a4da3d07e64d524243c/docopt_subcommands-2.3.0.tar.gz" } ], "2.3.1": [ { "comment_text": "", "digests": { "md5": "934eedddea192310fa186430370930cb", "sha256": "5f4b3f2da6bda71710b8413952f7e4126126b46377ec9a3d85dbb0714e3805e0" }, "downloads": -1, "filename": "docopt_subcommands-2.3.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "934eedddea192310fa186430370930cb", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 8870, "upload_time": "2017-11-09T06:49:12", "url": "https://files.pythonhosted.org/packages/53/14/2e2398c5684657a4dd0c4bb6c2d7c196de8d63b7096345153f21ad1bb553/docopt_subcommands-2.3.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c7a5311f48d6b7372e5ccb035ba80ac3", "sha256": "282384a07ef33ade005cfda65e37d5b43722a689d40f69645367eb38adf1f5c6" }, "downloads": -1, "filename": "docopt_subcommands-2.3.1.tar.gz", "has_sig": false, "md5_digest": "c7a5311f48d6b7372e5ccb035ba80ac3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7369, "upload_time": "2017-11-09T06:42:31", "url": "https://files.pythonhosted.org/packages/81/50/4c1f46f5e56bb65c10ce9d1e21417cf25e5412414dd7f8f747f3a2368b35/docopt_subcommands-2.3.1.tar.gz" } ], "2.3.2": [ { "comment_text": "", "digests": { "md5": "ad0384c96ee2bcff8473e1ddeb825c34", "sha256": "03c1acebd55f2b6cd1b667a4bf10d68d02a9c567e5783f2e928bdc40ab9d1b88" }, "downloads": -1, "filename": "docopt_subcommands-2.3.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ad0384c96ee2bcff8473e1ddeb825c34", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7027, "upload_time": "2018-11-07T08:31:12", "url": "https://files.pythonhosted.org/packages/d5/79/5a97357650e8f7c148313cb976a13424078401e9bc4b7054348d415bfafe/docopt_subcommands-2.3.2-py2.py3-none-any.whl" } ], "3.0.0": [ { "comment_text": "", "digests": { "md5": "25e654fb979b4f85b5dba2fa78513065", "sha256": "60712fc4cd8515925d2bb447c614eaf185136ceb0c8fb5313f839dda9198e90a" }, "downloads": -1, "filename": "docopt_subcommands-3.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "25e654fb979b4f85b5dba2fa78513065", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7005, "upload_time": "2018-12-22T12:47:46", "url": "https://files.pythonhosted.org/packages/28/8a/36db70d97186f802a650dbd448934552362cee2bd7ce7e0dfb0aeb2c077c/docopt_subcommands-3.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "89e373257b79e026a71f4f915365924d", "sha256": "03d2da508d876d41c147a3d668a1265568bacff9cbd63078bfcc92a00a4462ea" }, "downloads": -1, "filename": "docopt_subcommands-3.0.0.tar.gz", "has_sig": false, "md5_digest": "89e373257b79e026a71f4f915365924d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7664, "upload_time": "2018-12-22T12:47:40", "url": "https://files.pythonhosted.org/packages/75/bc/c3a2a5189c45483d4f33b06dae1d32ae5668f06d5fc8530b756dc7fbc932/docopt_subcommands-3.0.0.tar.gz" } ], "4.0.0": [ { "comment_text": "", "digests": { "md5": "11b5c1a9e8c6e726d7d067fc2183ac3c", "sha256": "5cbad12756b8429b8d5069306881fe87d3f135c71d8e85088deb64a13229e908" }, "downloads": -1, "filename": "docopt_subcommands-4.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "11b5c1a9e8c6e726d7d067fc2183ac3c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7367, "upload_time": "2019-06-23T17:11:12", "url": "https://files.pythonhosted.org/packages/20/e3/493d0a477e0b15a77d1e92d97a4447bde79280082b507bb57f3e68e4e064/docopt_subcommands-4.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "91e4472a7e28f8094d684e53ff9a76ad", "sha256": "e511c33f96474d754333617009443b1641c24e7614d051f8c0d5746670d2243a" }, "downloads": -1, "filename": "docopt_subcommands-4.0.0.tar.gz", "has_sig": false, "md5_digest": "91e4472a7e28f8094d684e53ff9a76ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8100, "upload_time": "2019-06-23T17:11:14", "url": "https://files.pythonhosted.org/packages/59/9f/90aa411d8d599b7e5c5d68742a03922242d576b770837a7517309fde14c6/docopt_subcommands-4.0.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "11b5c1a9e8c6e726d7d067fc2183ac3c", "sha256": "5cbad12756b8429b8d5069306881fe87d3f135c71d8e85088deb64a13229e908" }, "downloads": -1, "filename": "docopt_subcommands-4.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "11b5c1a9e8c6e726d7d067fc2183ac3c", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 7367, "upload_time": "2019-06-23T17:11:12", "url": "https://files.pythonhosted.org/packages/20/e3/493d0a477e0b15a77d1e92d97a4447bde79280082b507bb57f3e68e4e064/docopt_subcommands-4.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "91e4472a7e28f8094d684e53ff9a76ad", "sha256": "e511c33f96474d754333617009443b1641c24e7614d051f8c0d5746670d2243a" }, "downloads": -1, "filename": "docopt_subcommands-4.0.0.tar.gz", "has_sig": false, "md5_digest": "91e4472a7e28f8094d684e53ff9a76ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8100, "upload_time": "2019-06-23T17:11:14", "url": "https://files.pythonhosted.org/packages/59/9f/90aa411d8d599b7e5c5d68742a03922242d576b770837a7517309fde14c6/docopt_subcommands-4.0.0.tar.gz" } ] }