Project description
pexpect-executor
![Quality Gate Status](https://pypi-camo.freetls.fastly.net/c3f4fe5df085fea8d3bc60ca6fef38e2430a8bd3/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d41647269616e44435f706578706563742d6578656375746f72266d65747269633d616c6572745f737461747573)
Automate interactive CLI tools actions to create previews or tests in Python.
Preview
![preview.svg](https://pypi-camo.freetls.fastly.net/3d858dd528d119066705e821d23adb655dccb32b/68747470733a2f2f6769746c61622e636f6d2f41647269616e44432f706578706563742d6578656375746f722f7261772f322e312e302f646f63732f707265766965772e737667)
CLI examples
pexpect-executor --help
pexpect-executor --down --down --down --down --down --space --enter -- gitlabci-local -H -B
pexpect-executor --press a --press a --enter -- gitlabci-local
pexpect-executor --ctrl c -- gitlabci-local
Python examples
#!/usr/bin/env python3
# Modules libraries
from pexpect_executor import Executor
# Configure
Executor.configure(host='previews', tool='pexpect-executor')
# List
Executor('ls -la', workdir='/').\
finish()
# More
Executor('ls -la | more -5', delay_press=0.5, workdir='/').\
read().\
press('s').\
read().\
press('s').\
read().\
press('b').\
read().\
press('b').\
read().\
press(' ').\
read().\
wait(1).\
press(Executor.KEY_ENTER).\
read().\
wait(1).\
press('q').\
finish()
# Prompt
Executor('').\
finish()
Usage
Command |
|
pexpect-executor |
Automate interactive CLI tools actions |
Internal arguments |
|
-h, --help |
Show this help message |
--version |
Show the current version |
Configuration arguments |
|
--delay-init SECS |
Delay the initial action execution (in s, default: 1.0) |
--delay-press SECS |
Delay the press actions execution (in s, default: 0.5) |
--delay-prompt SECS |
Delay the prompt actions execution (in s, default: 1.0) |
--hold-prompt |
Hold the prompt execution without a new line |
--host HOST |
Configure the host name (default: preview, env: EXECUTOR_HOST) |
--tool TOOL |
Configure the tool name (default: executor, env: EXECUTOR_TOOL) |
--workdir WORKDIR |
Use a specific working directory path |
Actions arguments |
|
--up |
Press the <UP> key |
--down |
Press the <DOWN> key |
--left |
Press the <LEFT> key |
--right |
Press the <RIGHT> key |
--enter |
Press the <ENTER> key |
--space |
Press the <SPACE> key |
--press KEY |
Press the specified <KEY> |
--ctrl KEY |
Press the specified Ctrl+<KEY> |
--read |
Read the buffered data output (forced) |
--wait SECS |
Wait the specified time (in s, example: 1.0) |
--finish |
Finish the execution (forced) |
Positional arguments |
|
command |
Command arguments to execute (use -- to separate) |
Supported systems
Systems |
Supported |
Linux (shell) |
✓ |
macOS (shell) |
? |
Windows (shell) |
~ |
Android (Termux) |
✓ |
Dependencies
- colored: Terminal colors and styles
- pexpect: Interactive console applications controller
- setuptools: Build and manage Python packages
- wexpect: Windows alternative of pexpect
References
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution