Name | icommandlib JSON |
Version |
0.7.0
JSON |
| download |
home_page | |
Summary | Pythonic interactive command runner. |
upload_time | 2023-04-24 14:37:12 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7.0 |
license | MIT |
keywords |
subprocess
cli
interactive
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ICommandlib
[![Main branch status](https://github.com/crdoconnor/icommandlib/actions/workflows/regression.yml/badge.svg)](https://github.com/crdoconnor/icommandlib/actions/workflows/regression.yml)
Icommandlib is an interactive command line runner, designed (unlike pexpect) to be able to run command line applications in a virtual terminal window and take screenshots.
It was designed for building self rewriting, documentation generating tests [like this](https://github.com/hitchdev/hitchstory/tree/master/examples/commandline)
for interactive command line apps with the [hitchstory framework](https://hitchdev.com/icommandlib//hitchstory).
ICommandLib can take both terminal text screenshots and "stripshots" - terminal screenshots with all the white space to the right and bottom of the screen stripped.
## Example
favoritecolor.py:
```python
answer = input("favorite color:")
print(f"Your favorite color is {answer}")
answer = input("favorite movie:")
print(f"Your favorite color is {answer}")
```
With code:
```python
from icommandlib import ICommand
from commandlib import python
from pathlib import Path
process = ICommand(python("favoritecolor.py")).run()
process.wait_until_output_contains("favorite color:")
process.send_keys("red\n")
process.wait_until_output_contains("favorite movie:")
process.send_keys("the usual suspects\n")
process.wait_until_on_screen("favorite color")
process.wait_for_successful_exit()
Path("stripshot.txt").write_text(process.stripshot())
```
* When the code is run to completion.
The file contents of `stripshot.txt` will then be:
```favorite color:red
Your favorite color is red
favorite movie:the usual suspects
Your favorite color is the usual suspects```
With height 4 and width 41.
## Install
```bash
$ pip install icommandlib
```
## Using ICommandLib
- [Custom Screen Condition](https://hitchdev.com/icommandlib/using/custom-screen-condition)
- [Kill](https://hitchdev.com/icommandlib/using/kill)
- [Process properties](https://hitchdev.com/icommandlib/using/process-properties)
- [Screenshot](https://hitchdev.com/icommandlib/using/screenshot)
- [Screensize](https://hitchdev.com/icommandlib/using/screensize)
- [Send keys](https://hitchdev.com/icommandlib/using/send-keys)
- [Wait until successful exit](https://hitchdev.com/icommandlib/using/wait-until-successful-exit)
Raw data
{
"_id": null,
"home_page": "",
"name": "icommandlib",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.0",
"maintainer_email": "",
"keywords": "subprocess,cli,interactive",
"author": "",
"author_email": "Colm O'Connor <colm.oconnor.github@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a7/6b/600c0b4e9b91b92be7baad866e365ea0be7a0558de63a6ea7a14d5bf4055/icommandlib-0.7.0.tar.gz",
"platform": null,
"description": "# ICommandlib\n\n[![Main branch status](https://github.com/crdoconnor/icommandlib/actions/workflows/regression.yml/badge.svg)](https://github.com/crdoconnor/icommandlib/actions/workflows/regression.yml)\n\nIcommandlib is an interactive command line runner, designed (unlike pexpect) to be able to run command line applications in a virtual terminal window and take screenshots.\n\nIt was designed for building self rewriting, documentation generating tests [like this](https://github.com/hitchdev/hitchstory/tree/master/examples/commandline)\nfor interactive command line apps with the [hitchstory framework](https://hitchdev.com/icommandlib//hitchstory).\n\nICommandLib can take both terminal text screenshots and \"stripshots\" - terminal screenshots with all the white space to the right and bottom of the screen stripped.\n\n## Example\n\n\n\n\n\n\n\n\n\nfavoritecolor.py:\n\n```python\nanswer = input(\"favorite color:\")\nprint(f\"Your favorite color is {answer}\")\nanswer = input(\"favorite movie:\")\nprint(f\"Your favorite color is {answer}\")\n```\n\nWith code:\n\n```python\nfrom icommandlib import ICommand\nfrom commandlib import python\nfrom pathlib import Path\n\nprocess = ICommand(python(\"favoritecolor.py\")).run()\nprocess.wait_until_output_contains(\"favorite color:\")\nprocess.send_keys(\"red\\n\")\nprocess.wait_until_output_contains(\"favorite movie:\")\nprocess.send_keys(\"the usual suspects\\n\")\nprocess.wait_until_on_screen(\"favorite color\")\nprocess.wait_for_successful_exit()\n\nPath(\"stripshot.txt\").write_text(process.stripshot())\n\n```\n\n\n\n\n\n* When the code is run to completion.\n\nThe file contents of `stripshot.txt` will then be:\n\n```favorite color:red\nYour favorite color is red\nfavorite movie:the usual suspects\nYour favorite color is the usual suspects```\n\nWith height 4 and width 41.\n\n\n\n\n\n\n\n## Install\n\n```bash\n$ pip install icommandlib\n```\n\n## Using ICommandLib\n\n- [Custom Screen Condition](https://hitchdev.com/icommandlib/using/custom-screen-condition)\n- [Kill](https://hitchdev.com/icommandlib/using/kill)\n- [Process properties](https://hitchdev.com/icommandlib/using/process-properties)\n- [Screenshot](https://hitchdev.com/icommandlib/using/screenshot)\n- [Screensize](https://hitchdev.com/icommandlib/using/screensize)\n- [Send keys](https://hitchdev.com/icommandlib/using/send-keys)\n- [Wait until successful exit](https://hitchdev.com/icommandlib/using/wait-until-successful-exit)\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Pythonic interactive command runner.",
"version": "0.7.0",
"split_keywords": [
"subprocess",
"cli",
"interactive"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ac81110ed27313087058cee5327fb1b7d94d6e3bf2086a2593c7985afaafd24c",
"md5": "5b3e903c08f6937f7371db5fe73fbd94",
"sha256": "cd174fd5bb4963423a465d46d27a95d1db5decd09c7bb4df86dc09f5e52fa3e1"
},
"downloads": -1,
"filename": "icommandlib-0.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5b3e903c08f6937f7371db5fe73fbd94",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.0",
"size": 9127,
"upload_time": "2023-04-24T14:37:08",
"upload_time_iso_8601": "2023-04-24T14:37:08.539195Z",
"url": "https://files.pythonhosted.org/packages/ac/81/110ed27313087058cee5327fb1b7d94d6e3bf2086a2593c7985afaafd24c/icommandlib-0.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a76b600c0b4e9b91b92be7baad866e365ea0be7a0558de63a6ea7a14d5bf4055",
"md5": "cd3390e2eefb270ea413cd876a5a95ec",
"sha256": "fd7fd9a306a7235426b21a5ed069d0c347aef85a1dcfca64755438eebe3e29b5"
},
"downloads": -1,
"filename": "icommandlib-0.7.0.tar.gz",
"has_sig": false,
"md5_digest": "cd3390e2eefb270ea413cd876a5a95ec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.0",
"size": 9621,
"upload_time": "2023-04-24T14:37:12",
"upload_time_iso_8601": "2023-04-24T14:37:12.206130Z",
"url": "https://files.pythonhosted.org/packages/a7/6b/600c0b4e9b91b92be7baad866e365ea0be7a0558de63a6ea7a14d5bf4055/icommandlib-0.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-24 14:37:12",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "icommandlib"
}