Skip to main content

Pythonic interactive command runner.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icommandlib-0.7.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

icommandlib-0.7.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file icommandlib-0.7.0.tar.gz.

File metadata

  • Download URL: icommandlib-0.7.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for icommandlib-0.7.0.tar.gz
Algorithm Hash digest
SHA256 fd7fd9a306a7235426b21a5ed069d0c347aef85a1dcfca64755438eebe3e29b5
MD5 cd3390e2eefb270ea413cd876a5a95ec
BLAKE2b-256 a76b600c0b4e9b91b92be7baad866e365ea0be7a0558de63a6ea7a14d5bf4055

See more details on using hashes here.

File details

Details for the file icommandlib-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: icommandlib-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for icommandlib-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd174fd5bb4963423a465d46d27a95d1db5decd09c7bb4df86dc09f5e52fa3e1
MD5 5b3e903c08f6937f7371db5fe73fbd94
BLAKE2b-256 ac81110ed27313087058cee5327fb1b7d94d6e3bf2086a2593c7985afaafd24c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page