Choices¶
Use Choice objects in the choices list for more control over the display and formatting.
Choice.valueis the actual value returned when the choice is selected. Iflabelis not set, the object must implement__str__method.Choice.labelreplaces the text in the prompt display. (optional)Choice.descriptionadds secondary text to the choice. (optional)
from richer_prompt import Choice, Select
Select.ask(
"Do you want to continue?",
choices=[
Choice(value=False, label="No", description="Abort and exit"),
Choice(value=True, label="Yes", description="This action cannot be undone"),
]
)
Pass disabled=True to mark a choice as unselectable.
from richer_prompt import Choice, Select
Select.ask(
"Choose a plan tier:",
choices=[
"Free",
"Pro",
Choice("Enterprise", description="Consulting required", disabled=True),
]
)