{ "info": { "author": "Takafumi Arakaki", "author_email": "aka.tkf@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta" ], "description": "Traits CLI - CLI generator based on class traits\n================================================\n\nTraits CLI is based on `Enthought's Traits library `_.\n\nSome benefits:\n\n* Automatically set type (int/float/...) of command line argument.\n* Help string generation.\n* \"Deep value\"\" configuration:\n e.g., ``--dict['a']['b']['c']=1`` is equivalent to\n ``obj.dict['a']['b']['c'] = 1`` in Python code.\n* Nested class configuration:\n e.g., ``--sub.attr=val`` is equivalent to\n ``obj.sub.attr = val`` in Python code.\n* Parameter file support (ini/conf, json, yaml, etc.).\n Load parameter from file then set attribute.\n\n.. _traits: https://github.com/enthought/traits\n\n\nLinks\n-----\n\n* `Documentaions (at Read the Docs) `_\n* `Source code repository (at GitHub) `_\n* `Issue tracker (at GitHub) `_\n* `PyPI `_\n* `Travis CI `_\n\n\nInstallation\n------------\n::\n\n pip install traitscli\n\n\nDependencies\n------------\n\n- traits_\n- argparse (for Python < 2.7)\n\n\nSample\n------\n\n\nSource code::\n\n from traitscli import TraitsCLIBase\n from traits.api import Bool, Float, Int, Str, Enum\n\n\n class SampleCLI(TraitsCLIBase):\n\n '''\n Sample CLI using `traitscli`.\n\n Example::\n\n %(prog)s --yes # => obj.yes = True\n %(prog)s --string something # => obj.string = 'string'\n %(prog)s --choice x # => raise error (x is not in {a, b, c})\n\n '''\n\n # These variables are configurable by command line option\n yes = Bool(desc='yes flag for sample CLI', config=True)\n no = Bool(True, config=True)\n fnum = Float(config=True)\n inum = Int(config=True)\n string = Str(config=True)\n choice = Enum(['a', 'b', 'c'], config=True)\n\n # You can have \"internal\" attributes which cannot be set via CLI.\n not_configurable_from_cli = Bool()\n\n def do_run(self):\n names = self.class_trait_names(config=True)\n width = max(map(len, names))\n for na in names:\n print \"{0:{1}} : {2!r}\".format(na, width, getattr(self, na))\n\n\n if __name__ == '__main__':\n # Run command line interface\n SampleCLI.cli()\n\n\nExample run::\n\n $ python sample.py --help\n usage: sample.py [-h] [--choice {a,b,c}] [--fnum FNUM] [--inum INUM] [--no]\n [--string STRING] [--yes]\n\n Sample CLI using `traitscli`.\n\n Example::\n\n sample.py --yes # => obj.yes = True\n sample.py --string something # => obj.string = 'string'\n sample.py --choice x # => raise error (x is not in {a, b, c})\n\n optional arguments:\n -h, --help show this help message and exit\n --choice {a,b,c} (default: a)\n --fnum FNUM (default: 0.0)\n --inum INUM (default: 0)\n --no (default: True)\n --string STRING (default: )\n --yes yes flag for sample CLI (default: False)\n\n $ python sample.py --yes --choice a\n string : ''\n no : True\n fnum : 0.0\n choice : 'a'\n inum : 0\n yes : True\n\n $ python sample.py --inum invalid_argument\n usage: sample.py [-h] [--choice {a,b,c}] [--fnum FNUM] [--inum INUM] [--no]\n [--string STRING] [--yes]\n sample.py: error: argument --inum: invalid int value: 'invalid_argument'", "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/tkf/traitscli", "keywords": "CLI,traits", "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "traitscli", "package_url": "https://pypi.org/project/traitscli/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/traitscli/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/tkf/traitscli" }, "release_url": "https://pypi.org/project/traitscli/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "traitscli - CLI generator based on class traits", "version": "0.1.0" }, "last_serial": 800863, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "eebf8c3b9ae7b5818faea93006d169e5", "sha256": "fd6a2f803653c31f49753b33b80aa51485664e44916c3e134fdd85325fa7aac1" }, "downloads": -1, "filename": "traitscli-0.1.0.tar.gz", "has_sig": false, "md5_digest": "eebf8c3b9ae7b5818faea93006d169e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10906, "upload_time": "2013-03-22T20:09:14", "url": "https://files.pythonhosted.org/packages/60/bb/4cc306529d2232b7f19361ef0eb98e80323b4db8b1f63878a92ac64a71d3/traitscli-0.1.0.tar.gz" } ], "0.1.beta0": [ { "comment_text": "", "digests": { "md5": "52c523e1e032d06f5ca9f60b4708e8f0", "sha256": "c07033ea9e27440e014eba917617f695cf1b1d1b17560f44132fe41215b7de8f" }, "downloads": -1, "filename": "traitscli-0.1.beta0.tar.gz", "has_sig": false, "md5_digest": "52c523e1e032d06f5ca9f60b4708e8f0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10846, "upload_time": "2012-10-10T20:57:51", "url": "https://files.pythonhosted.org/packages/e1/91/1dffa948449677858aa4e4bb6b644a78c782bf54e9a7b638e566b0b70839/traitscli-0.1.beta0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "eebf8c3b9ae7b5818faea93006d169e5", "sha256": "fd6a2f803653c31f49753b33b80aa51485664e44916c3e134fdd85325fa7aac1" }, "downloads": -1, "filename": "traitscli-0.1.0.tar.gz", "has_sig": false, "md5_digest": "eebf8c3b9ae7b5818faea93006d169e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10906, "upload_time": "2013-03-22T20:09:14", "url": "https://files.pythonhosted.org/packages/60/bb/4cc306529d2232b7f19361ef0eb98e80323b4db8b1f63878a92ac64a71d3/traitscli-0.1.0.tar.gz" } ] }