Pythonic task execution library for managing shell-oriented subprocesses and organizing executable Python code into CLI-invokable tasks
Overall
score
96%
Build a task automation system that executes interactive shell commands and automatically responds to prompts by monitoring output patterns.
Implement two task functions that execute commands which prompt for user input. Your implementation should automatically respond to these prompts by watching for specific patterns in the command output.
Execute a simulated deployment command (e.g., a script that echoes "Do you want to continue? (yes/no):" and waits for input). The task should automatically respond with "yes\n" when this pattern is detected.
Execute a simulated secure command (e.g., a script that echoes "Enter passphrase:" and waits for input). The task should automatically respond with "secret123\n" when this pattern is detected.
automated_deployment task executes a Python script that prints "Do you want to continue? (yes/no):" to stdout and reads from stdin. The task automatically responds with "yes\n" and the script prints "Continuing..." and exits with code 0. @testsecure_operation task executes a Python script that prints "Enter passphrase:" to stdout and reads from stdin. The task automatically responds with "secret123\n" and the script prints "Access granted" and exits with code 0. @test@generates
from invoke import task, Context
@task
def automated_deployment(c: Context) -> None:
"""
Execute a simulated deployment command that prompts for confirmation.
Runs a command that outputs "Do you want to continue? (yes/no):"
and automatically responds with "yes\n".
Args:
c: Invoke context object for running commands
"""
pass
@task
def secure_operation(c: Context) -> None:
"""
Execute a simulated secure command that prompts for a passphrase.
Runs a command that outputs "Enter passphrase:"
and automatically responds with "secret123\n".
Args:
c: Invoke context object for running commands
"""
passProvides task automation and subprocess execution capabilities.
Install with Tessl CLI
npx tessl i tessl/pypi-invokedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10