update docs with new prompt option

This commit is contained in:
Grant Ramsay 2023-06-30 20:42:15 +01:00
parent 8de138ea6a
commit 6df890cdce
No known key found for this signature in database
GPG Key ID: 40EDDC3F71696632
1 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,13 @@ If you supply a list of choices, the prompt will loop until the user enters one
>>> from rich.prompt import Prompt
>>> name = Prompt.ask("Enter your name", choices=["Paul", "Jessica", "Duncan"], default="Paul")
By default this is case sensitive, but you can set `case_insensitive=True` to make it case sensitive::
>>> from rich.prompt import Prompt
>>> name = Prompt.ask("Enter your name", choices=["Paul", "Jessica", "Duncan"], default="Paul", case_insensitive=True)
Now, it would accept "paul" or "Paul" as valid responses.
In addition to :class:`~rich.prompt.Prompt` which returns strings, you can also use :class:`~rich.prompt.IntPrompt` which asks the user for an integer, and :class:`~rich.prompt.FloatPrompt` for floats.
The :class:`~rich.prompt.Confirm` class is a specialized prompt which may be used to ask the user a simple yes / no question. Here's an example::