{ "info": { "author": "Altertech", "author_email": "div@altertech.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: User Interfaces" ], "description": "# icli - interactive command line interfaces\n\n## What is icli\n\n**icli** is a Python library, built on top of **argparse**, which allows you to\nquickly build rich interactive command line interfaces with sections, command\nhistory, command batch processing, command repeating and interactive\nauto-complete.\n\n\n\n**icli** uses **readline** library for command inputs.\n\n## Features\n\n* Jump between command sections (use / for root section, .. or Ctrl-d to jump\n to upper section)\n\n* Send multiple commands, separated with *;*\n\n* Repeat command execution, by adding *|X* to the end of input (X - delay in\n seconds between commands, use *|cX* to clear screen before next command\n execution)\n\n* Auto-completion (via **argcomplete**)\n\n## How to install\n\n```\npip3 install icli\n```\n\n## How to use\n\n* use **icli.ArgumentParser** just like **argparse.ArgumentParser** (create\n parsers, sub-parsers etc.)\n\n* create dispatcher method for commands. This method receives parsed arguments\n in \\*\\*kwargs:\n\n```python\n\ndef dispatcher(**kwargs):\n # ....\n```\n\n* define CLI sections tree and start interactive mode:\n\n```python\nimport icli\nap = icli.ArgumentParser()\n\n# ...\n\nap.sections = {'user': ['account', 'apikey'], 'document': []}\nap.run = dispatcher\nap.interactive()\n```\n\n## Customizing\n\nOverride:\n\n* **get_interactive_prompt** customize input prompt\n* **print_repeat_title** customize title for repeating commands\n* **handle_interactive_exception** handle exceptions, raised during interactive\n loop\n\n## Global commands\n\nYou may define global commands, which work in all sections, e.g. let's make *w*\nsystem command executed, when user type *w*:\n\n```python\ndef w(*args):\n # the method receives command name and optional command arguments in *args\n import os\n os.system('w')\n\nap.interactive_global_commands['w'] = w\n```\n\nNote: global commands are not auto-completed\n\n## History file\n\nIf history file is defined, input commands are loaded before interactive\nsession is started and saved at the end.\n\n```python\nap.interactive_history_file = '~/.test-icli'\n```\n\nBy default, last 100 commands are saved. To change this behavior, modify:\n\n```python\nap.interactive_history_length = 500\n```\n\n## Combining shell and interactive CLI\n\nLet's launch interactive mode when your program is started without arguments,\notherwise process them:\n\n```python\nimport sys\n\n# prog param sets program name in help to empty for interactive mode\nap = icli.ArgumentParser(prog='' if len(sys.argv) < 2 else None)\n\n# ...\n\nif len(sys.argv) > 1:\n ap.launch()\nelse:\n ap.interactive()\n```\n\n## Batch processing\n\nYour program may read commands from stdin or external file, then process them\nwithout user input\n\nTo do this, put commands to I/O steam and launch **batch** method:\n\n```python\nimport io\n\nf = io.StringIO()\nf.write('user account list ; user apikey list\\ndocument list')\nf.seek(0)\nap.batch(f)\n```\n\nor just launch **batch** method with a source stream:\n\n```python\nwith open('commands.list') as cf:\n ap.batch(cf)\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/alttch/icli", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "icli", "package_url": "https://pypi.org/project/icli/", "platform": "", "project_url": "https://pypi.org/project/icli/", "project_urls": { "Homepage": "https://github.com/alttch/icli" }, "release_url": "https://pypi.org/project/icli/0.0.8/", "requires_dist": null, "requires_python": "", "summary": "Interactive CLI builder", "version": "0.0.8" }, "last_serial": 5907154, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "e4c7157f8e2225995f9d9d1bb471133e", "sha256": "b505628a63a59ee27f0c599f3477308326188e16e9fd44a241d2fce9d829a536" }, "downloads": -1, "filename": "icli-0.0.1.tar.gz", "has_sig": false, "md5_digest": "e4c7157f8e2225995f9d9d1bb471133e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3091, "upload_time": "2019-09-29T00:31:23", "url": "https://files.pythonhosted.org/packages/17/04/274e22cc378a81506f31fbec92835ec5988f19b595623c003daf7dcfdb70/icli-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "c006126beea40300bffbbc11adfd63c7", "sha256": "12039d3b233b469551e4bc0be4df95b9b08796eba116adfcbe16e7f4238b0925" }, "downloads": -1, "filename": "icli-0.0.2.tar.gz", "has_sig": false, "md5_digest": "c006126beea40300bffbbc11adfd63c7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4808, "upload_time": "2019-09-29T20:11:19", "url": "https://files.pythonhosted.org/packages/d5/5b/2c1e6f4948b98b2fe4c561b8bd7f889570092eac0fc1d5b9976dff0543ba/icli-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "96777e19f08b9ee969d5f465c3d9e07d", "sha256": "f37fe00bff6e4776a9158acd74a80a21fc2ac8a08b51dfa063e4df5630a0b1d4" }, "downloads": -1, "filename": "icli-0.0.3.tar.gz", "has_sig": false, "md5_digest": "96777e19f08b9ee969d5f465c3d9e07d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4892, "upload_time": "2019-09-29T20:48:19", "url": "https://files.pythonhosted.org/packages/8e/d7/913216e379d974838597240163c77ea773b3d578eb456fe2be53426ffe7a/icli-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "0327d3c84eb3388f441456e93fe3985f", "sha256": "8d43767017fa1a5dd60869d1685b54ec6085965da499015860a7c7c6edcb9f0e" }, "downloads": -1, "filename": "icli-0.0.4.tar.gz", "has_sig": false, "md5_digest": "0327d3c84eb3388f441456e93fe3985f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4973, "upload_time": "2019-09-29T23:22:56", "url": "https://files.pythonhosted.org/packages/8f/c1/2c74850b3ee23e34df4c47e194571f2bf0cf0f554d6fcb253177d9cfe34a/icli-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "b2b8175994e756b3e7f23866ac2b8944", "sha256": "7b9eadcfb8cf8d5b830b8bcb109f6e40db5b8fec9ea74ae17d1a324b9f9ccecc" }, "downloads": -1, "filename": "icli-0.0.5.tar.gz", "has_sig": false, "md5_digest": "b2b8175994e756b3e7f23866ac2b8944", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4978, "upload_time": "2019-09-30T01:02:29", "url": "https://files.pythonhosted.org/packages/b4/9c/e28469adb134a7f87052a516bcf6feceb29d7d6a8f3bd562c49f6c0dedbf/icli-0.0.5.tar.gz" } ], "0.0.7": [ { "comment_text": "", "digests": { "md5": "975c7aa2a4d29471bee0124716fd3a7a", "sha256": "5e888cf3e913e8623b52ec53c53ee1dd1044f3416e7aa8a3064966e95d383888" }, "downloads": -1, "filename": "icli-0.0.7.tar.gz", "has_sig": false, "md5_digest": "975c7aa2a4d29471bee0124716fd3a7a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5010, "upload_time": "2019-09-30T14:22:02", "url": "https://files.pythonhosted.org/packages/88/13/700efa6ce92627f7a0787e1227b7513c6f849a0b8c1e48ee414fbabb7910/icli-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "6294f7f496d642c3c96404c7f1817c75", "sha256": "ebe2fc9f94496755aa5f766f5981c814333b82f437f44706c111eb508bef880d" }, "downloads": -1, "filename": "icli-0.0.8.tar.gz", "has_sig": false, "md5_digest": "6294f7f496d642c3c96404c7f1817c75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5028, "upload_time": "2019-09-30T14:24:32", "url": "https://files.pythonhosted.org/packages/c8/1f/679290ec550b755ae72db2a2d539ee6bb6500ddf4d0d5682512f7862c35d/icli-0.0.8.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6294f7f496d642c3c96404c7f1817c75", "sha256": "ebe2fc9f94496755aa5f766f5981c814333b82f437f44706c111eb508bef880d" }, "downloads": -1, "filename": "icli-0.0.8.tar.gz", "has_sig": false, "md5_digest": "6294f7f496d642c3c96404c7f1817c75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5028, "upload_time": "2019-09-30T14:24:32", "url": "https://files.pythonhosted.org/packages/c8/1f/679290ec550b755ae72db2a2d539ee6bb6500ddf4d0d5682512f7862c35d/icli-0.0.8.tar.gz" } ] }