Skip to main content

ICommandlib

Main branch status

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

Metadata

Release files for icommandlib 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for icommandlib 0.8.0
File Size Uploaded
icommandlib-0.8.0.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for icommandlib 0.8.0
File Interpreter ABI Platform
icommandlib-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.8 kB

Release files / icommandlib-0.8.0.tar.gz

Download URL icommandlib-0.8.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
6dba8454a6ff801a0f80470f18c51aa071bba0597c64277ba0bac8fea2deafff
BLAKE2b-256 checksum
How to use checksums
4ba4493a811855c1fdd4eeb0d01733d453884389ec0904d62ec3a8d6996c20a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / icommandlib-0.8.0-py3-none-any.whl

Download URL icommandlib-0.8.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e3f5c269da8a65248eda9d81b067840ecf3a55b86da9e9498d162b47d6dd04e
BLAKE2b-256 checksum
How to use checksums
8f01f7a7dcb36f271351dcbe25eb45bdfbb6417e01524c87788be58c53c568c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.8.0 This release

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page