Skip to content


GitHub Repo starsPyPI - Downloads

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 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.


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("")).run()
process.wait_until_output_contains("favorite color:")
process.wait_until_output_contains("favorite movie:")
process.send_keys("the usual suspects\n")
process.wait_until_on_screen("favorite color")

  • 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


$ pip install icommandlib

Using ICommandLib