cape.tnakit.promptutils: Interactive Console Prompt

This module provides for interactive command-line prompts, including support for BASH color modifications. By default, it will display prompts in green, and user-responses will use the system text color.

cape.tnakit.promptutils.prompt(txt, vdef=None, color='green')

Get user input using a colorized prompt

Call:
>>> v = prompt(txt, vdef=None)
Inputs:
txt: str

Text of the question on the same line as prompt

vdef: {None} | str

Default value (if any)

color: {"green"} | str

Color name

Outputs:
v: None | str

Raw (unevaluated) input from input() function

Versions:
  • 2018-08-23 @ddalle: Version 1.0 (in aerohub)

  • 2021-08-24 @ddalle: Version 1.1
    • was prompt_color()

    • returns None on empty response