{ "info": { "author": "Cameron Simpson", "author_email": "cs@cskk.id.au", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Release 20190729:\nBaseCommand: support for a USAGE_FORMAT usage message format string and a getopt_error_handler method.\n\n\n\n## Class `BaseCommand`\n\nA base class for handling nestable command lines.\n\nThis class provides the basic parse and dispatch mechanisms\nfor command lines.\nTo implement a command line\none instantiates a subclass of BaseCommand:\n\n class MyCommand(BaseCommand):\n GETOPT_SPEC = 'ab:c'\n USAGE_FORMAT = r\"\"\"Usage: {cmd} [-a] [-b bvalue] [-c] [--] arguments...\n -a Do it all.\n -b But using bvalue.\n -c The 'c' option!\n \"\"\"\n ...\n the_cmd = MyCommand()\n\nRunning a command is done by:\n\n the_cmd.run(argv)\n\nThe subclass is customised by overriding the following methods:\n* `apply_defaults(options)`:\n prepare the initial state of `options`\n before any command line options are applied\n* `apply_opts(options,opts)`:\n apply the `opts` to `options`.\n `opts` is an option value mapping\n as returned by `getopot.getopt`.\n* `cmd_`*subcmd*`(argv,options)`:\n if the command line options are followed by an argument\n whose value is *subcmd*,\n then method `cmd_`*subcmd*`(argv,options)`\n will be called where `argv` contains the command line arguments\n after *subcmd*.\n* `main(argv,options)`:\n if there are no command line aguments after the options\n or the first argument does not have a corresponding\n `cmd_`*subcmd* method\n then method `main(argv,options)`\n will be called where `argv` contains the command line arguments.\n* `run_context(argv,options,cmd)`:\n a context manager to provide setup or teardown actions\n to occur before and after the command implementation respectively.\n If the implementation is a `cmd_`*subcmd* method\n then this is called with `cmd=`*subcmd*;\n if the implementation is `main`\n then this is called with `cmd=None`.\n\nTo aid recursive use\nit is intended that all the per command state\nis contained in the `options` object\nand therefore that in typical use\nall of `apply_opts`, `cmd_`*subcmd*, `main` and `run_context`\nshould be static methods making no reference to `self`.\n\nEditorial: why not arparse?\nPrimarily because when incorrectly invoked\nan argparse command line prints the help/usage messgae\nand aborts the whole programme with `SystemExit`.\n\n## Function `docmd(dofunc)`\n\nDecorator for Cmd subclass methods\nto supply some basic quality of service.\n\nThis decorator:\n- wraps the function call in a `cs.pfx.Pfx` for context\n- intercepts `getopt.GetoptError`s, issues a `warning`\n and runs `self.do_help` with the method name,\n then returns `None`\n- intercepts other `Exception`s,\n issues an `exception` log message\n and returns `None`\n\nThe intended use is to decorate `cmd.Cmd` `do_`* methods:\n\n from cmd import Cmd\n class MyCmd(Cmd):\n @docmd\n def do_something(...):\n ... do something ...\n\n\n\n# Release Log\n\nRelease 20190729:\nBaseCommand: support for a USAGE_FORMAT usage message format string and a getopt_error_handler method.\n\nRelease 20190619.1:\nAnother niggling docstring formatting fix.\n\nRelease 20190619:\nMinor documentation updates.\n\nRelease 20190617.2:\nLint.\n\nRelease 20190617.1:\nInitial release with @docmd decorator and alpha quality BaseCommand command line assistance class.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/cameron_simpson/css/commits/all", "keywords": "python2,python3", "license": "GNU General Public License v3 or later (GPLv3+)", "maintainer": "", "maintainer_email": "", "name": "cs.cmdutils", "package_url": "https://pypi.org/project/cs.cmdutils/", "platform": "", "project_url": "https://pypi.org/project/cs.cmdutils/", "project_urls": { "Homepage": "https://bitbucket.org/cameron_simpson/css/commits/all" }, "release_url": "https://pypi.org/project/cs.cmdutils/20190729/", "requires_dist": null, "requires_python": "", "summary": "convenience functions for working with the Cmd module and other command line related stuff", "version": "20190729" }, "last_serial": 5597686, "releases": { "20190617.2": [ { "comment_text": "", "digests": { "md5": "c0946fb581c57a2bc78ed3b0e263935f", "sha256": "2f3e976c71275591d209284374c8db92b2065870f4d8354994a8fee444fac151" }, "downloads": -1, "filename": "cs.cmdutils-20190617.2.tar.gz", "has_sig": false, "md5_digest": "c0946fb581c57a2bc78ed3b0e263935f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4820, "upload_time": "2019-06-17T02:23:59", "url": "https://files.pythonhosted.org/packages/0c/4b/1e1b56b66e296e8d7311fd75136418bf2d5f24b25795764fa3eed01613f8/cs.cmdutils-20190617.2.tar.gz" } ], "20190619": [ { "comment_text": "", "digests": { "md5": "26472cb47bf238d811293ad312a392c3", "sha256": "5217cfe769a2ed67a3482453587f6e7af9b6206218040e8f8bc05a9c8a52c422" }, "downloads": -1, "filename": "cs.cmdutils-20190619.tar.gz", "has_sig": false, "md5_digest": "26472cb47bf238d811293ad312a392c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4875, "upload_time": "2019-06-18T22:35:04", "url": "https://files.pythonhosted.org/packages/05/85/5356f1808dc1baf4e4e9edf64f02ed485926e3a44573313329b281623ced/cs.cmdutils-20190619.tar.gz" } ], "20190619.1": [ { "comment_text": "", "digests": { "md5": "bbd044426d5325341c6ce1c7c6aa5f51", "sha256": "74acf65e9c2af4392433b044e318245f4cca11fc487bb776c03b34b0cfadf609" }, "downloads": -1, "filename": "cs.cmdutils-20190619.1.tar.gz", "has_sig": false, "md5_digest": "bbd044426d5325341c6ce1c7c6aa5f51", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4879, "upload_time": "2019-06-18T22:40:20", "url": "https://files.pythonhosted.org/packages/ae/84/d229a41b5e44c2ca1efb13bb94bd95fb9f756516bc857113abe5937351cc/cs.cmdutils-20190619.1.tar.gz" } ], "20190729": [ { "comment_text": "", "digests": { "md5": "b023766b580eb5d489e888d4d0e78fae", "sha256": "a05f77c248396ec5f152c4d950b52b77782498ae5f4b85849e50c2fc00d5f27d" }, "downloads": -1, "filename": "cs.cmdutils-20190729.tar.gz", "has_sig": false, "md5_digest": "b023766b580eb5d489e888d4d0e78fae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5626, "upload_time": "2019-07-29T05:05:18", "url": "https://files.pythonhosted.org/packages/e9/fb/d44898656696d1d0ad6a2f1af51fef8ace330447e97b47a8c646ef91595c/cs.cmdutils-20190729.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b023766b580eb5d489e888d4d0e78fae", "sha256": "a05f77c248396ec5f152c4d950b52b77782498ae5f4b85849e50c2fc00d5f27d" }, "downloads": -1, "filename": "cs.cmdutils-20190729.tar.gz", "has_sig": false, "md5_digest": "b023766b580eb5d489e888d4d0e78fae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5626, "upload_time": "2019-07-29T05:05:18", "url": "https://files.pythonhosted.org/packages/e9/fb/d44898656696d1d0ad6a2f1af51fef8ace330447e97b47a8c646ef91595c/cs.cmdutils-20190729.tar.gz" } ] }