{ "info": { "author": "Michael Merickel", "author_email": "oss@m.merickel.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "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" ], "description": "========\nsubparse\n========\n\nA wrapper for argparse that provides decorator-based subcommand support.\n\nCommands can be defined separately from their actual main functions,\nenabling faster import times.\n\nBasic Usage\n===========\n\n::\n\n from subparse import CLI\n\n class MyApp(object):\n def __init__(self, quiet=False):\n self.quiet = quiet\n\n def info(self, *msg):\n if not self.quiet:\n print('[info]', *msg)\n\n def context_factory(cli, args):\n return MyApp(args.quiet)\n\n def generic_options(parser):\n parser.add_argument('--quiet', action='store_true',\n help='turn of debugging')\n\n cli = CLI(version='0.0', context_factory=context_factory)\n cli.add_generic_options(generic_options)\n\n @cli.command(__name__ + ':foo_main')\n def foo(parser):\n \"\"\"\n a short description ending in a period.\n\n a longer description\n \"\"\"\n parser.add_argument('--bar', action='store_true',\n help='turn on bar')\n\n def foo_main(app, args):\n app.info('Hello World!')\n\n result = cli.run()\n sys.exit(result)\n\nLazy Decorators\n===============\n\nCommands can be defined lazily and picked up later. This removes ordering\nrestrictions between the commands and the cli object.\n\nA module containing commands can be defined irrespective of the actual\n``CLI`` instance:\n\n::\n\n # myapp/info.py\n\n from subparse import command\n\n @command('myapp.info:foo_main')\n def foo(parser):\n \"\"\"perform foo\"\"\"\n\nLater, when an instance of a ``CLI`` is created, the commands can be loaded\nand registered:\n\n::\n\n cli = CLI()\n cli.load_commands('myapp.info')\n\nEntry Points\n============\n\nCommands may also be defined in external modules and loaded via entry\npoints.\n\n::\n\n from subparse import cli\n\n cli = CLI()\n cli.load_commands_from_entry_point('myapp.commands')\n\nAn extension application would then define the external module that should\nbe searched for commands. Again this allows the commands themselves to be\ndefined independently of the main functions, improving import speed.\n\nAn extension package should define a module containing the supported\ncommands:\n\n::\n\n # barpkg/commands.py\n\n from subparse import command\n\n @command('barpkg.bar')\n def bar(parser):\n \"\"\"perform bar\"\"\"\n\nThe package should also define the function to be called for each command.\nOptionally in a separate module to avoid importing run-time dependencies\nduring parsing:\n\n::\n\n # barpkg/bar.py\n\n def main(app, args):\n pass\n\nThe package can then broadcast the module ``barpkg.commands``\ncontaining the supported commands:\n\n::\n\n [myapp.commands]\n barpkg = barpkg.commands\n\nNow when your extension package is installed the commands will automatically\nbecome available.\n\nContext Factory\n===============\n\nEach subcommand, when executed, is passed a context object which defines a\nreusable API between subcommands. This is really the secret sauce of\n``subparse`` that makes it really easy to build your own shared CLI features.\n\nThe ``context_factory`` argument to the ``subparse.CLI`` allows for defining\nan object that is passed to all commands. This factory can also be a\ngenerator, allowing it to ``yield`` the context object and then cleanup\nafter the command is complete. For example:\n\n::\n\n import transaction\n\n def context_factory(cli, args):\n tm = transaction.TransactionManager(explicit=True)\n with tm:\n yield tm\n\nIn the above example the transaction manager is available to all subcommands\nand it can commit/abort based on whether the command raises an exception.\n\nEach subcommand can pass custom kwargs to the context factory via the\n``context_kwargs`` argument. For example, if a single subcommand wishes to\nopt-out of the transaction manager:\n\n::\n\n def context_factory(cli, args, without_tm=False):\n if without_tm:\n yield\n\n tm = transaction.TransactionManager(explicit=True)\n with tm:\n yield tm\n\n @command(..., context_kwargs=dict(without_tm=True))\n def foo(parser):\n \"\"\"\" Run a command without the tm enabled.\"\"\"\n\n\n0.5.3 (2019-03-09)\n==================\n\n- Output help to ``sys.stderr`` when parsing fails.\n\n- Support passing ``context_kwargs`` to the ``command`` decorator. These\n arguments will be passed to the ``context_factory`` when the command is\n executed.\n\n0.5.2 (2019-03-09)\n==================\n\n- Sort subcommands in help output.\n\n0.5.1 (2019-03-08)\n==================\n\n- Use the ``argparse.RawTextHelpFormatter`` formatter class.\n\n0.5 (2019-03-08)\n================\n\n- Add Python 3.7 support.\n\n- Fix a deprecation warning coming from setuptools.\n\n- Conform more closely to PEP-257 for docstring parsing.\n\n- Modify how the help text is displayed using the\n ``argparse.RawDescriptionHelpFormatter`` formatter class.\n\n0.4 (2018-05-03)\n================\n\n- Drop Python 2.6, 3.2 and 3.3 support.\n\n- Add Python 3.4, 3.5, 3.6 support.\n\n- Allow the ``context_factory`` to be a generator which yields the context.\n This allows the context to wrap the full lifecycle of the CLI.\n\n0.3.3 (2013-08-12)\n==================\n\nNo functional changes from 0.3.2.\n\n- Improve documentation.\n\n0.3.2 (2013-08-06)\n==================\n\n- Add `CLI.run` API for simply executing the command line.\n\n0.3.1 (2013-08-06)\n==================\n\n- Improve the help output.\n\n0.3 (2013-08-06)\n================\n\n- Rename subcommands to commands in the API.\n\n0.2 (2013-08-06)\n================\n\n- Underscores in function names are converted to dashes in their respective\n subcommand names.\n- Add `CLI.add_generic_options` API.\n- Add a new `help` subcommand, allowing for `myapp help foo`.\n- Allow relative imports in the subcommand specification.\n\n0.1 (2013-08-05)\n================\n\n- Initial Commits\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mmerickel/subparse", "keywords": "argparse,cli,commandline,subcommand", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "subparse", "package_url": "https://pypi.org/project/subparse/", "platform": "", "project_url": "https://pypi.org/project/subparse/", "project_urls": { "Homepage": "https://github.com/mmerickel/subparse" }, "release_url": "https://pypi.org/project/subparse/0.5.3/", "requires_dist": [ "pytest ; extra == 'testing'", "pytest-cov ; extra == 'testing'" ], "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "summary": "A command line helper library for extensible subcommands", "version": "0.5.3" }, "last_serial": 4919994, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "84682588bfe48f41dbc73d01630975fc", "sha256": "57b527d3c15614f807c1c78e7478410460689cb6603d362188defcb3f88a86cf" }, "downloads": -1, "filename": "subparse-0.1.tar.gz", "has_sig": false, "md5_digest": "84682588bfe48f41dbc73d01630975fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4580, "upload_time": "2013-08-05T07:06:51", "url": "https://files.pythonhosted.org/packages/c3/99/436bd49bf22ec946ce71b653c2497d76893956f373dafc3e9a1c023a257f/subparse-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "0a81d40069f96608ca73f0d45790c35e", "sha256": "f87c872c6e469587f0b23aaaa21523ec325c7d1b577f53a307e05f77bd8c48db" }, "downloads": -1, "filename": "subparse-0.2.tar.gz", "has_sig": false, "md5_digest": "0a81d40069f96608ca73f0d45790c35e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6566, "upload_time": "2013-08-06T08:24:52", "url": "https://files.pythonhosted.org/packages/1c/2d/7ebf522f2763235b09df11767b9d26c11bdcfb68295060175159395b202a/subparse-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "4193b9ecf1d9b7d4d31631e811f044a3", "sha256": "591986cc57af1497819c536beb3b15c0d2c3f8ea4e97591da0f0773ec97b28b1" }, "downloads": -1, "filename": "subparse-0.3.tar.gz", "has_sig": false, "md5_digest": "4193b9ecf1d9b7d4d31631e811f044a3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6515, "upload_time": "2013-08-06T18:43:56", "url": "https://files.pythonhosted.org/packages/6a/59/654a2ae0b649a2659ad3dd5080b332d4988bfa831757eae5894c4ba555dc/subparse-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "084763ee43889664ba34e1a12341b7a6", "sha256": "e628a9e1c70f7ec641ac0adc8929abee02b7f8d1ab2ae44cefe4dee16df0f838" }, "downloads": -1, "filename": "subparse-0.3.1.tar.gz", "has_sig": false, "md5_digest": "084763ee43889664ba34e1a12341b7a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6540, "upload_time": "2013-08-06T18:47:15", "url": "https://files.pythonhosted.org/packages/50/8e/2483830f69842ac9c7ef05e5a5954ea8f33ca1c0b73d959e1d672e2dd109/subparse-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "a096819c13489267c943328c1a02b761", "sha256": "b4083a05df0715d809f60c67ed894d00d9935744662e20df290f1bf992014e5d" }, "downloads": -1, "filename": "subparse-0.3.2.tar.gz", "has_sig": false, "md5_digest": "a096819c13489267c943328c1a02b761", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6933, "upload_time": "2013-08-06T19:19:18", "url": "https://files.pythonhosted.org/packages/86/fe/1b150f84cc5d8abf70d41fd03f9b3a9931761406d339a5b8361ee406d792/subparse-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "d6ebae6bd7384b96e106231e6ed2f22e", "sha256": "92f1cb04429876646529f9cf4e460db3b013f9be86860910cd69e1906b9595c7" }, "downloads": -1, "filename": "subparse-0.3.3.tar.gz", "has_sig": false, "md5_digest": "d6ebae6bd7384b96e106231e6ed2f22e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7790, "upload_time": "2013-08-12T20:46:41", "url": "https://files.pythonhosted.org/packages/af/7b/65d18691f78ecccd07d4b0c2c40511bc7f585f86973ba5cf88eef9e2b0df/subparse-0.3.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "b7ae5df903ca6c9e88e696132da1a2b0", "sha256": "51e609af65bb2fc7f6624a8fd71faa28008b52fce5d01c0e062d7e6216ead7b1" }, "downloads": -1, "filename": "subparse-0.4-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "b7ae5df903ca6c9e88e696132da1a2b0", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9365, "upload_time": "2018-05-03T17:38:23", "url": "https://files.pythonhosted.org/packages/89/91/ef3280094bfb7589d3a6eafbd627136331a8b5f7012181f87874a06c596f/subparse-0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f0b4e19d202a5e053be3a7651d3d48b5", "sha256": "424fc75db33f39b201cd5efa7b3ddedfb4ab9d2dca2adfedefcfa42d3447ceb8" }, "downloads": -1, "filename": "subparse-0.4.tar.gz", "has_sig": true, "md5_digest": "f0b4e19d202a5e053be3a7651d3d48b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9729, "upload_time": "2018-05-03T17:38:24", "url": "https://files.pythonhosted.org/packages/41/38/de2688998c88ee6aa87ddcff4e41718c531467eb789d7db35b0490f0cde6/subparse-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "7e96d22ab39cbbae36d0d9b2d3def671", "sha256": "02be638dfb2a8a8c9580ea8ac23ab37ac9d22e4aabbcb98491d773662e89f7c3" }, "downloads": -1, "filename": "subparse-0.5-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "7e96d22ab39cbbae36d0d9b2d3def671", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9994, "upload_time": "2019-03-08T17:23:28", "url": "https://files.pythonhosted.org/packages/b4/13/e11c3e42516584e7891b2e81240efe2dba8a9eb02424025120c9458dc294/subparse-0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "224064326a684d00ba69d673b39cb021", "sha256": "4076308fee1308bdcd38b6c175709ba42f8c20befc4651839a36b679295f5ef3" }, "downloads": -1, "filename": "subparse-0.5.tar.gz", "has_sig": true, "md5_digest": "224064326a684d00ba69d673b39cb021", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10452, "upload_time": "2019-03-08T17:23:29", "url": "https://files.pythonhosted.org/packages/34/15/39f83f486d39e08ae250d2923603c2d687c68af9fb0c85787ee7da7a1e45/subparse-0.5.tar.gz" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "153f000cfd7b43891c8c18dd1a5178e7", "sha256": "a87002106f84579568d3cf0a49f48414534716e11af09beaffdb461fa1cc69eb" }, "downloads": -1, "filename": "subparse-0.5.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "153f000cfd7b43891c8c18dd1a5178e7", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10101, "upload_time": "2019-03-08T17:39:21", "url": "https://files.pythonhosted.org/packages/d0/74/c495fc987903556f906b182338b58c50b8dfe245c07ffc9105ff64f114a3/subparse-0.5.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf50ac5932a08d43142bee70f94c4f7c", "sha256": "f62a3a0b4f2e6e94d4099585d5f6b725dfeee8d76f7eaf9c4ed352356d53579a" }, "downloads": -1, "filename": "subparse-0.5.1.tar.gz", "has_sig": true, "md5_digest": "cf50ac5932a08d43142bee70f94c4f7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10555, "upload_time": "2019-03-08T17:39:22", "url": "https://files.pythonhosted.org/packages/67/95/36217dbdb838961cde7fb6cb1de6af11fcf21535cfd15e78ebe8efc1ca17/subparse-0.5.1.tar.gz" } ], "0.5.2": [ { "comment_text": "", "digests": { "md5": "7bd96a67062fd0b9f201eb54f1fa8a2f", "sha256": "94c9ab1f6ac3c157ff212e53cd105fca94fc667a2c6304ff8ba2c899bdac2063" }, "downloads": -1, "filename": "subparse-0.5.2-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "7bd96a67062fd0b9f201eb54f1fa8a2f", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 8393, "upload_time": "2019-03-09T18:47:33", "url": "https://files.pythonhosted.org/packages/8a/0d/80a4c636e1c8e707bd3fa34cbd98a87c1a6c9fd759fd8417b9e910ba7d70/subparse-0.5.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a704dbd5cc001e05a5ce19cd161715e8", "sha256": "1a5b794db53089c1b05b5b925dac033a49cf7bc7c7c5ba0031d2b599eb17632c" }, "downloads": -1, "filename": "subparse-0.5.2.tar.gz", "has_sig": true, "md5_digest": "a704dbd5cc001e05a5ce19cd161715e8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11385, "upload_time": "2019-03-09T18:47:35", "url": "https://files.pythonhosted.org/packages/62/3f/6ead90e42569d20cee2e33339fedaaebfd979f4749c83cb95508c8f4195d/subparse-0.5.2.tar.gz" } ], "0.5.3": [ { "comment_text": "", "digests": { "md5": "4693655a04a7d0c71dd951c72d37812b", "sha256": "4f9bba29586e59414485b4b7d65881baa887d699cc5f8018d499fa63a7ab91f7" }, "downloads": -1, "filename": "subparse-0.5.3-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "4693655a04a7d0c71dd951c72d37812b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 8702, "upload_time": "2019-03-10T00:16:42", "url": "https://files.pythonhosted.org/packages/ec/4d/cc9c12bcbff2a02e3b9d210e33509ae5b630d165f98910593f205e820535/subparse-0.5.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc4b0ec2bfc94b00a801363892645f7d", "sha256": "f935d161ee63446f233af326e6c5f6163b39e62ad7c1c51c59bfccded241f2d8" }, "downloads": -1, "filename": "subparse-0.5.3.tar.gz", "has_sig": true, "md5_digest": "fc4b0ec2bfc94b00a801363892645f7d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11855, "upload_time": "2019-03-10T00:16:43", "url": "https://files.pythonhosted.org/packages/90/8b/39e06466eb65588240cb53297e4b191e136376e3190c4b65bfa440485dfc/subparse-0.5.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4693655a04a7d0c71dd951c72d37812b", "sha256": "4f9bba29586e59414485b4b7d65881baa887d699cc5f8018d499fa63a7ab91f7" }, "downloads": -1, "filename": "subparse-0.5.3-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "4693655a04a7d0c71dd951c72d37812b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 8702, "upload_time": "2019-03-10T00:16:42", "url": "https://files.pythonhosted.org/packages/ec/4d/cc9c12bcbff2a02e3b9d210e33509ae5b630d165f98910593f205e820535/subparse-0.5.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc4b0ec2bfc94b00a801363892645f7d", "sha256": "f935d161ee63446f233af326e6c5f6163b39e62ad7c1c51c59bfccded241f2d8" }, "downloads": -1, "filename": "subparse-0.5.3.tar.gz", "has_sig": true, "md5_digest": "fc4b0ec2bfc94b00a801363892645f7d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", "size": 11855, "upload_time": "2019-03-10T00:16:43", "url": "https://files.pythonhosted.org/packages/90/8b/39e06466eb65588240cb53297e4b191e136376e3190c4b65bfa440485dfc/subparse-0.5.3.tar.gz" } ] }