Choices

Use Choice objects in the choices list for more control over the display and formatting.

  • Choice.value is the actual value returned when the choice is selected. If label is not set, the object must implement __str__ method.

  • Choice.label replaces the text in the prompt display. (optional)

  • Choice.description adds 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"),
    ]
)
select Do you want to continue? 1. NoAbort and exit 2. YesThis action cannot be undone ↑↓ to navigate · Enter to select

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),
    ]
)
select Choose a plan tier: 1. Free 2. Pro 3. EnterpriseConsulting required ↑↓ to navigate · Enter to select