CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-invoke

Pythonic task execution library for managing shell-oriented subprocesses and organizing executable Python code into CLI-invokable tasks

Overall
score

96%

Overview
Eval results
Files

task.mdevals/scenario-4/

Interactive Command Executor

Build a task automation system that executes interactive shell commands and automatically responds to prompts by monitoring output patterns.

Requirements

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.

Task 1: Automated Deployment

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.

Task 2: Secure Operation

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.

Test Cases

Test 1: Confirmation Prompt { .test }

  • The 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. @test

Test 2: Passphrase Prompt { .test }

  • The secure_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

Test 3: Command Completion { .test }

  • Both tasks complete successfully without manual intervention, demonstrating that the automatic response mechanism works correctly. @test

Implementation

@generates

API

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
    """
    pass

Dependencies { .dependencies }

invoke { .dependency }

Provides task automation and subprocess execution capabilities.

Install with Tessl CLI

npx tessl i tessl/pypi-invoke

tile.json