{ "info": { "author": "Arthibus Giss\u00e9hel", "author_email": "public-dev-cltools@gissehel.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Programming Language :: Python :: 2", "Topic :: System :: Shells", "Topic :: Terminals", "Topic :: Utilities" ], "description": "cltools\n=======\n\nSet of decorators of to create transform a class into a command-line tool\n\nImagine, you've got a class you want to use from the command line, without having\nto explicitly parse the command line and make all the routing stuff.\n\nThat's what's ``cltools`` is doing by proving decorators on class and methods to make your\nclass runnable, and transform your method into commands.\n\n``cltools`` create command tools like git/hg/svn/apt-get/apt-cache/..., that means your\ntool will have commands\n\nsimple example :\n----------------\n\nImagine, you've got a simple class that make tasks, and you want to make a command line tool\nwith that. Let's say, it's a calculator module ``calclib.py``:\n\n.. code:: python\n\n #!/usr/bin/env python\n \n class Calc(object) :\n def __init__(self) :\n pass\n def add(self, value1, value2) :\n return value1+value2\n def mult(self, value1, value2) :\n return value1*value2\n\nThen, we will write a simple class and transform into a runnable tool:\n\n.. code:: python\n\n #!/usr/bin/env python\n \n import sys\n from calclib import Calc\n from cltools import CLRunner\n from supertools import superable\n \n @CLRunner.runnable()\n @superable\n class CalcTool(object) :\n '''A simple command-line wrapper for calclib''' \n def __init__(self) :\n self._calc = Calc()\n \n \n def get_two_params(self, args) :\n if len(args) != 2 :\n # errorexit provided by CLRunnable parent\n self.errorexit(\"Need two values VALUE1 and VALUE2 as arguments\")\n try :\n value1 = int(args[0])\n except Exception :\n self.errorexit(\"Value [%s] should be a valid number\" % (args[0],))\n try :\n value2 = int(args[1])\n except Exception :\n self.errorexit(\"Value [%s] should be a valid number\" % (args[1],))\n return value1, value2\n \n @CLRunner.command()\n def add(self, args, kwargs) :\n '''Add two values VALUE1 and VALUE2 given as parameters'''\n value1, value2 = self.get_two_params(args)\n value = self._calc.add(value1, value2)\n self.status(\"Result : [%s]\" % (value,))\n \n @CLRunner.command()\n def mult(self, args, kwargs) :\n '''Multiplie two values VALUE1 and VALUE2'''\n value1, value2 = self.get_two_params(args)\n value = self._calc.mult(value1, value2)\n self.status(\"Result : [%s]\" % (value,))\n \n @CLRunner.command()\n def help(self, args=[], kwargs={}) :\n '''Get this help'''\n self.__super.help()\n \n if __name__ == '__main__' :\n calctool = CalcTool()\n if not(calctool.run( sys.argv )) :\n sys.exit(1)\n\nNow we can test our command line tool::\n\n $ ./calc.py\n Usage: calc.py COMMAND_NAME [OPTION] [VALUES]\n A simple command-line wrapper for calclib\n\n Commands:\n add Add two values VALUE1 and VALUE2 given as parameters\n help Get this help\n mult Multiplie two values VALUE1 and VALUE2\n \n Error : Need a command name\n\n::\n \n $ ./calc.py add 4 17\n Result : [21]\n\n::\n \n $ ./calc.py add 15 66 33\n Error : Need two values VALUE1 and VALUE2 as arguments\n\nNote that the help is aumatically generate based on commands declared in the class, \nand the online doc attached to the class and methods.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/gissehel/cltools.git", "keywords": "commandline tools cltools decorator", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "cltools", "package_url": "https://pypi.org/project/cltools/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/cltools/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/gissehel/cltools.git" }, "release_url": "https://pypi.org/project/cltools/0.4.2/", "requires_dist": null, "requires_python": null, "summary": "Set of decorators of to create transform a class into a command-line tool.", "version": "0.4.2" }, "last_serial": 743080, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e3431eafaee0b89d0298d288ebe6b8e1", "sha256": "815519bdd937285b5dfe48a90f885896665a175a95b0fd10b31a5cfd7846bf24" }, "downloads": -1, "filename": "cltools-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e3431eafaee0b89d0298d288ebe6b8e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5327, "upload_time": "2013-04-14T12:44:53", "url": "https://files.pythonhosted.org/packages/dc/a2/67da2d2da5dcd3b176e32378de4f3922bc9a8e42fed96cc19779c8e1753f/cltools-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "3669a3570d5879189504b2edb1ec11c2", "sha256": "82f1037b46cfb16f91da6ffc67c117c3e7c4261fbaebeaa6273028bfbd9fd22b" }, "downloads": -1, "filename": "cltools-0.1.1.tar.gz", "has_sig": false, "md5_digest": "3669a3570d5879189504b2edb1ec11c2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5404, "upload_time": "2013-04-14T13:00:11", "url": "https://files.pythonhosted.org/packages/8e/b8/bb6dea04fc1030d0a93984ce46b0a284737c7b3bd262032ed1c9b3c5e1be/cltools-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "035a1395c0fa9f8ae0cd7e3485fcf2f2", "sha256": "d348d4947f0c35fbd49e0855623619b1339660d6c4ba12c66f20be6d68d42bf9" }, "downloads": -1, "filename": "cltools-0.1.2.tar.gz", "has_sig": false, "md5_digest": "035a1395c0fa9f8ae0cd7e3485fcf2f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5435, "upload_time": "2013-04-14T13:04:09", "url": "https://files.pythonhosted.org/packages/94/9f/0ab16503d35f8e1c3f76c74014d268c555e97c0cbb1d82f5cad7ec67c26d/cltools-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "646cfeb34722d67b09407ddc9c8c9a53", "sha256": "f9a447d377e83fbf09de9b413273c5204ab8b0ed38c5f4d718a906962277e7f7" }, "downloads": -1, "filename": "cltools-0.2.0.tar.gz", "has_sig": false, "md5_digest": "646cfeb34722d67b09407ddc9c8c9a53", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6452, "upload_time": "2013-04-14T13:25:44", "url": "https://files.pythonhosted.org/packages/89/94/3ed5c9db9107a1edd0ccad8508c1a51f23a86c44912b1576463800b67c1c/cltools-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "3e25562c2417b13df75c73852c83915e", "sha256": "58b60b44d628e0b7178ec9b2ab364b1bf3d470acf3670dcd5a5fcc691744cbae" }, "downloads": -1, "filename": "cltools-0.3.0.tar.gz", "has_sig": false, "md5_digest": "3e25562c2417b13df75c73852c83915e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7349, "upload_time": "2013-04-19T20:17:45", "url": "https://files.pythonhosted.org/packages/ab/d1/8f15f9ac8b314022c0ead63a84fae0178d4c0abc85c228180576e0e68b9a/cltools-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "822ff856715536ddf6a0b994fe597e57", "sha256": "6ef6c237947bd768d6b6bdd097afbc78f99e388df033181df00ec871a6c979ec" }, "downloads": -1, "filename": "cltools-0.3.1.tar.gz", "has_sig": false, "md5_digest": "822ff856715536ddf6a0b994fe597e57", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6699, "upload_time": "2013-05-02T08:08:21", "url": "https://files.pythonhosted.org/packages/2a/a8/c8ada2080dc5ef31bc5bcc0e2d8013226f0f166cfb82d8b00f7a994d2caf/cltools-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "6b2a572df905419bf7f9cb81e789fc1f", "sha256": "0632f8cc1e96cf899065cbb675580d0234d3b4ffff549a4ef37ce47987fabc35" }, "downloads": -1, "filename": "cltools-0.3.2.tar.gz", "has_sig": false, "md5_digest": "6b2a572df905419bf7f9cb81e789fc1f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6732, "upload_time": "2013-05-04T13:17:16", "url": "https://files.pythonhosted.org/packages/63/39/cf1f6322edb60c4ff1653cc7d15ebefa9b6802b177da88da713cfc2c38ad/cltools-0.3.2.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "f0028678f72d7bcbd5c63b75ce44cf4c", "sha256": "aca91161701109d32d98597182c537d6cb81b49ecf873918131f0fae26288fde" }, "downloads": -1, "filename": "cltools-0.4.0.tar.gz", "has_sig": false, "md5_digest": "f0028678f72d7bcbd5c63b75ce44cf4c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6845, "upload_time": "2013-05-04T15:09:51", "url": "https://files.pythonhosted.org/packages/fe/50/77e86771113a13a5a725a1d02be27e38873c2794945b3c4d6146e17d6884/cltools-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "4cf444bd7e4422383b44295dd52a28a2", "sha256": "634e3aff88591b1a4679b6fe2717ac26b30da1fbe34db1ceedfabba2abaefca8" }, "downloads": -1, "filename": "cltools-0.4.1.tar.gz", "has_sig": false, "md5_digest": "4cf444bd7e4422383b44295dd52a28a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6951, "upload_time": "2013-05-04T17:11:52", "url": "https://files.pythonhosted.org/packages/c7/a3/0f63fbd660cea6e6611f6372a95db223d704f809797acb5da5b1e5e97e07/cltools-0.4.1.tar.gz" } ], "0.4.2": [ { "comment_text": "", "digests": { "md5": "40986e9f184b23386ace872996481e06", "sha256": "55a4cf9846370e6332a3506229a745caa11ed05408cae9b5437105d91c558f58" }, "downloads": -1, "filename": "cltools-0.4.2.tar.gz", "has_sig": false, "md5_digest": "40986e9f184b23386ace872996481e06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6954, "upload_time": "2013-05-06T10:03:42", "url": "https://files.pythonhosted.org/packages/26/8a/87cfb32666434ad42668c660aaa4b2b3ba4ea342410db1f075c65c327238/cltools-0.4.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "40986e9f184b23386ace872996481e06", "sha256": "55a4cf9846370e6332a3506229a745caa11ed05408cae9b5437105d91c558f58" }, "downloads": -1, "filename": "cltools-0.4.2.tar.gz", "has_sig": false, "md5_digest": "40986e9f184b23386ace872996481e06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6954, "upload_time": "2013-05-06T10:03:42", "url": "https://files.pythonhosted.org/packages/26/8a/87cfb32666434ad42668c660aaa4b2b3ba4ea342410db1f075c65c327238/cltools-0.4.2.tar.gz" } ] }