Provide interactive prompting and lightweight dialog utilities
Source: target-root/usr/local/lib/solidgroundux/common/ui-ask.sh
Provide interactive prompting and lightweight dialog utilities
Public functions
- Ask for a single typed value
- ask_datetime
- Ask for a canonical symbolic decision
- Show an interruptible auto-continue countdown
- Select one or more values from a numbered list
- Ask for a value from a choice list
- Ask for a choice with instant single-key acceptance
- Prompt for multiple named fields
Internal functions
| Function | Purpose | Arguments | Output |
|---|---|---|---|
_sgnd_lib_guard | Ensure direct execution is rejected and record that the library has been sourced. | — | — |
_ask_expand_choices | Expand a comma-separated choice specification into one choice per line. | - $1 — Choice specification to expand. | Writes one expanded choice per line to stdout. |
_ask_choice_is_valid | Validate a single choice against a ask_choose-style choices list. | - $1 — VALUE | — |
_ask_build_prompt | Build the colored prompt string used by ask-style input functions. | - $1 — Label text. | Writes the prompt string to stdout. |
_ask_validate | Run a validation callback when provided. | - $1 — VALIDATE_FUNCTION | — |
_ask_decision_expand_choices | Expand a decision choice specification into canonical/alias pairs. | - $1 — Decision specification, for example "YES\ | Y,NO\ |
_ask_decision_normalize | Convert a typed decision or alias into its canonical decision value. | - $1 — Typed value to normalize. | Writes the canonical decision value to stdout. |
_ask_decision_display | Build a compact display string from a decision specification. | - $1 — CHOICES | Writes display string, e.g. YES/NO. |
_ask_decision_map_dlg_rc | Convert ask_dlg_autocontinue return codes into canonical decision values. | - $1 — Return code from ask_dlg_autocontinue. | Writes the mapped canonical decision value to stdout. |
_ask_parse_fieldspec | Split a form field specification into the temporary parser globals used by ask_prompt_form. | - $1 — Field specification in KEY\ | LABEL\ |
_ask_is_ident | Test whether a value is a valid shell variable identifier. | - $1 — VALUE | — |
_ask_datetime_normalize | Normalize an absolute date/time value or SolidGroundUX datetime shortcut. | — | — |
Description
Provides the framework's console interaction layer.
The library:
- Prompts for typed input using labeled questions
- Supports editable defaults and validation hooks
- Supports constrained symbolic decisions
- Supports timed auto-continue prompts with simple intervention keys
- Supports typed and immediate choice selection helpers
- Supports normalized absolute and relative datetime input through ask_datetime
- Supports prompting a variable set from field-spec lines
- Reads input from the controlling terminal to avoid stdin conflicts
Public API:
- ask
- ask_datetime
- ask_decision
- ask_dlg_autocontinue
- ask_selection
- ask_choose
- ask_choose_immediate
- ask_prompt_form
