diff --git a/docs/source/prompt.rst b/docs/source/prompt.rst index 088aa8e7..ef708ca1 100644 --- a/docs/source/prompt.rst +++ b/docs/source/prompt.rst @@ -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 \ No newline at end of file + python -m rich.prompt