-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Similar to #41, I'm looking to provide extra information about the choices. Currently I'm using including this info in Choice.name, but this messes with fuzzy.
Perhaps I could change the long instruction on "hover"?
Here's a simplified example:
import dataclasses
from InquirerPy import inquirer
from InquirerPy.base.control import Choice
@dataclasses.dataclass
class Fruit:
name: str
description: str
fruits = [
Fruit(
"Apple",
"A common, round fruit produced by the tree Malus domestica, cultivated in temperate climates.",
),
Fruit(
"Bananna",
"A banana is an elongated, edible fruit - botanically a berry - produced by several kinds of large herbaceous flowering plants in the genus Musa.",
),
Fruit(
"Peach",
"The peach (Prunus persica) is a deciduous tree first domesticated and cultivated in Zhejiang province of Eastern China.",
),
]
max_name_len = max(len(f.name) for f in fruits)
choices = [Choice(f, f.name.ljust(max_name_len + 1) + f.description) for f in fruits]
inquirer.fuzzy("Pick a fruit", choices).execute()zyf722
Metadata
Metadata
Assignees
Labels
No labels
