yera.console.prompts
Reusable Rich Prompt subclasses and prompt helper functions for terminal input.
Symbols
ButtonsPrompt
PromptPrompt that shows a numbered list and returns the selected option string.
Methods
ButtonsPrompt.pre_prompt
pre_prompt() → NoneDisplay label and numbered list before the prompt.
ButtonsPrompt.process_response
process_response(
value: str,
) → strParse choice number and return the selected option string.
DatePrompt
PromptPrompt that validates YYYY-MM-DD and returns the date string.
Methods
DatePrompt.process_response
process_response(
value: str,
) → strValidate ISO date and return the string.
prompt_buttons
prompt_buttons(
console: Console,
options: list[str],
label: str | None = None,
) → strShow numbered options and prompt for a choice (1-n). Returns the selected option string.
prompt_date
prompt_date(
console: Console,
label: str,
default_date: date,
) → strPrompt for a date (YYYY-MM-DD), re-prompt until valid. Returns ISO date string.
prompt_slider
prompt_slider(
console: Console,
label: str,
min_value: float,
max_value: float,
default: float,
) → floatShow slider prompt (label, range, default) and return validated float in range.
prompt_text
prompt_text(
console: Console,
message: str,
) → strPrompt for a single line of text. Returns the string entered.
SliderPrompt
FloatPromptFloatPrompt that enforces min/max range. Raise InvalidResponse if out of range.
Methods
SliderPrompt.process_response
process_response(
value: str,
) → floatParse float and validate it is within min/max range.
SliderPrompt.ask_range
ask_range(
label: str,
min_value: float,
max_value: float,
default: float,
console: Console | None = None,
) → floatAsk for a float within the given range. Builds prompt from label and range.