or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/invoke@2.2.x
tile.json

tessl/pypi-invoke

tessl install tessl/pypi-invoke@2.2.0

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

Agent Success

Agent success rate when using this tile

96%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.25x

Baseline

Agent success rate without this tile

77%

task.mdevals/scenario-6/

Interactive Terminal Input Handler

Build a Python utility that handles raw character input from the terminal and adapts output based on terminal dimensions.

Requirements

Your implementation should provide two main capabilities:

1. Raw Character Input Handler

Create a function that reads individual characters from the terminal in real-time without waiting for Enter to be pressed. The function should:

  • Read characters one at a time as they are typed
  • Return immediately after each keypress
  • Work correctly with standard input streams
  • Restore normal terminal behavior after reading is complete

2. Terminal Dimension Reporter

Create a function that detects and reports the current terminal size. The function should:

  • Detect the current width (columns) and height (rows) of the terminal
  • Work across different terminal types and environments
  • Return dimensions as a tuple or dictionary with clear labels
  • Handle cases where terminal size cannot be determined gracefully

Implementation

@generates

API

def read_character():
    """
    Read a single character from terminal input without waiting for Enter.

    Returns:
        str: A single character that was pressed
    """
    pass

def get_terminal_size():
    """
    Get the current terminal dimensions.

    Returns:
        dict: Dictionary with 'width' and 'height' keys representing columns and rows
    """
    pass

Test Cases

  • When read_character() is called and the user presses 'a', it returns 'a' immediately without requiring Enter @test
  • When get_terminal_size() is called in a terminal with 80 columns and 24 rows, it returns a dictionary with width=80 and height=24 @test
  • When get_terminal_size() is called in an environment without a terminal, it handles the situation gracefully without crashing @test

Dependencies { .dependencies }

invoke { .dependency }

Provides terminal control and PTY utilities for low-level terminal operations.