Skip to content

Interactive Fuzzy-Filter or Keyboard-Driven Prompt #2453

Answered by KyleKing
KyleKing asked this question in Q&A
Discussion options

You must be logged in to vote

TLDR: not supported in rich (#392 (comment) & #266 (comment)), but possible with textual (#1843 (comment)) or could be done with questionary. This is partially related: #960

However, after looking at a bunch of the rich example apps, it seems like a common workaround is to provide indexing, so you could do something like:

choices = ["fix","feat","docs"]

for idx, choice in enumerate(choices):
    console.print(f"{idx}. {choice}")
selection = Prompt.ask('Which option?', choices=[*map(str, range(len(choices)))], default="0")

Look like:

0. fix
1. feat
2. docs
Which option? [0/1/2] (0):

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by KyleKing
Comment options

You must be logged in to vote
2 replies
@KyleKing
Comment options

@FergusFettes
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants