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.7.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.7.0
File Size Uploaded
icommandlib-0.7.0.tar.gz 9.6 kB Details

Built distribution (wheel)

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

Total release size: 18.7 kB

Release files / icommandlib-0.7.0.tar.gz

Download URL icommandlib-0.7.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fd7fd9a306a7235426b21a5ed069d0c347aef85a1dcfca64755438eebe3e29b5
BLAKE2b-256 checksum
How to use checksums
a76b600c0b4e9b91b92be7baad866e365ea0be7a0558de63a6ea7a14d5bf4055
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.7.0-py3-none-any.whl

Download URL icommandlib-0.7.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd174fd5bb4963423a465d46d27a95d1db5decd09c7bb4df86dc09f5e52fa3e1
BLAKE2b-256 checksum
How to use checksums
ac81110ed27313087058cee5327fb1b7d94d6e3bf2086a2593c7985afaafd24c
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

0.8.0

2 release files

This release

0.7.0 This release

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