Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra choice info for select/fuzzy #55

Open
Gracecr opened this issue Feb 7, 2023 · 0 comments · May be fixed by #56
Open

Extra choice info for select/fuzzy #55

Gracecr opened this issue Feb 7, 2023 · 0 comments · May be fixed by #56

Comments

@Gracecr
Copy link

Gracecr commented Feb 7, 2023

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()

tmp

Gracecr pushed a commit to Gracecr/InquirerPy that referenced this issue Feb 13, 2023
Allows the developer to specify additional information to appear next to their choices.

kazhala#55
Gracecr added a commit to Gracecr/InquirerPy that referenced this issue Feb 13, 2023
Allows the developer to specify additional information to appear next to their choices.

kazhala#55
Gracecr added a commit to Gracecr/InquirerPy that referenced this issue Feb 13, 2023
Allows the developer to specify additional information to appear next to their choices.

kazhala#55
@Gracecr Gracecr linked a pull request Feb 13, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant