Pythonic interactive command runner.
Project description
ICommandlib
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 for interactive command line apps with the hitchstory framework.
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:
answer = input("favorite color:")
print(f"Your favorite color is {answer}")
answer = input("favorite movie:")
print(f"Your favorite color is {answer}")
With code:
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:
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file icommandlib-0.8.0.tar.gz.
File metadata
- Download URL: icommandlib-0.8.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dba8454a6ff801a0f80470f18c51aa071bba0597c64277ba0bac8fea2deafff
|
|
| MD5 |
b291dc70ba3bd1bc0c3121a9695c1b8c
|
|
| BLAKE2b-256 |
4ba4493a811855c1fdd4eeb0d01733d453884389ec0904d62ec3a8d6996c20a1
|
File details
Details for the file icommandlib-0.8.0-py3-none-any.whl.
File metadata
- Download URL: icommandlib-0.8.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e3f5c269da8a65248eda9d81b067840ecf3a55b86da9e9498d162b47d6dd04e
|
|
| MD5 |
454f17dc2d731a95ed57b7b6e22dae5e
|
|
| BLAKE2b-256 |
8f01f7a7dcb36f271351dcbe25eb45bdfbb6417e01524c87788be58c53c568c4
|