or run

tessl search
Log in

Version

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

tessl/pypi-questionary

tessl install tessl/pypi-questionary@2.1.0

Python library to build pretty command line user prompts with interactive forms and validation

Agent Success

Agent success rate when using this tile

96%

Improvement

Agent success rate improvement when using this tile compared to baseline

1x

Baseline

Agent success rate without this tile

96%

task.mdevals/scenario-7/

Command Line City Search Tool

Build a command-line tool that helps users search and select cities from a database using an interactive autocomplete prompt.

Requirements

Create a Python script named city_search.py that:

  1. City Database: Maintains a list of at least 15 cities with their countries.

  2. Interactive Autocomplete Prompt: Presents an interactive prompt with the question "Search for a city:" that provides autocomplete suggestions as the user types. The autocomplete should:

    • Match city names when the user types partial text
    • Be case-insensitive
    • Display the country name alongside each city in the suggestions
  3. Display Selection: After the user selects a city, print: You selected: {city}, {country}

  4. Handle Cancellation: If the user cancels the prompt, print: Search cancelled.

Example Cities to Include

Your database should include at least these cities (you may add more):

  • Paris (France)
  • London (United Kingdom)
  • New York (United States)
  • Tokyo (Japan)
  • Sydney (Australia)
  • Berlin (Germany)
  • Toronto (Canada)
  • Madrid (Spain)
  • Rome (Italy)
  • Amsterdam (Netherlands)
  • Barcelona (Spain)
  • Vienna (Austria)
  • Prague (Czech Republic)
  • Dublin (Ireland)
  • Stockholm (Sweden)

Example Interaction

When the user runs the script, they should see an autocomplete prompt. As they type, matching cities should appear in a dropdown. After selecting a city, they should see a confirmation like:

You selected: Paris, France

Test Cases

  • The autocomplete prompt activates and shows suggestions when the user types @test
  • Typing "par" (lowercase) matches "Paris" regardless of case @test
  • The selected city and country are correctly displayed after selection @test

Dependencies { .dependencies }

questionary { .dependency }

Provides interactive command-line prompts with autocomplete functionality.

@generates