mirror of https://github.com/Textualize/rich.git
update docs with new prompt option
This commit is contained in:
parent
8de138ea6a
commit
6df890cdce
|
@ -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::
|
||||
|
@ -30,4 +37,4 @@ The Prompt class was designed to be customizable via inheritance. See `prompt.py
|
|||
|
||||
To see some of the prompts in action, run the following command from the command line::
|
||||
|
||||
python -m rich.prompt
|
||||
python -m rich.prompt
|
||||
|
|
Loading…
Reference in New Issue