|
|
None | __init__ (self, TextType prompt="", *Optional[Console] console=None, bool password=False, Optional[List[str]] choices=None, bool show_default=True, bool show_choices=True) |
| |
|
Union[DefaultType, PromptType] | ask (cls, TextType prompt="", *Optional[Console] console=None, bool password=False, Optional[List[str]] choices=None, bool show_default=True, bool show_choices=True, DefaultType default, Optional[TextIO] stream=None) |
| |
|
PromptType | ask (cls, TextType prompt="", *Optional[Console] console=None, bool password=False, Optional[List[str]] choices=None, bool show_default=True, bool show_choices=True, Optional[TextIO] stream=None) |
| |
| Any | ask (cls, TextType prompt="", *Optional[Console] console=None, bool password=False, Optional[List[str]] choices=None, bool show_default=True, bool show_choices=True, Any default=..., Optional[TextIO] stream=None) |
| |
| Text | render_default (self, DefaultType default) |
| |
| Text | make_prompt (self, DefaultType default) |
| |
| str | get_input (cls, Console console, TextType prompt, bool password, Optional[TextIO] stream=None) |
| |
| bool | check_choice (self, str value) |
| |
| PromptType | process_response (self, str value) |
| |
| None | on_validate_error (self, str value, InvalidResponse error) |
| |
| None | pre_prompt (self) |
| |
|
PromptType | __call__ (self, *Optional[TextIO] stream=None) |
| |
|
Union[PromptType, DefaultType] | __call__ (self, *DefaultType default, Optional[TextIO] stream=None) |
| |
| Any | __call__ (self, *Any default=..., Optional[TextIO] stream=None) |
| |
Ask the user for input until a valid response is received. This is the base class, see one of
the concrete classes for examples.
Args:
prompt (TextType, optional): Prompt text. Defaults to "".
console (Console, optional): A Console instance or None to use global console. Defaults to None.
password (bool, optional): Enable password input. Defaults to False.
choices (List[str], optional): A list of valid choices. Defaults to None.
show_default (bool, optional): Show default in prompt. Defaults to True.
show_choices (bool, optional): Show choices in prompt. Defaults to True.
| Any pip._vendor.rich.prompt.PromptBase.ask |
( |
|
cls, |
|
|
TextType |
prompt = "", |
|
|
*Optional[Console] |
console = None, |
|
|
bool |
password = False, |
|
|
Optional[List[str]] |
choices = None, |
|
|
bool |
show_default = True, |
|
|
bool |
show_choices = True, |
|
|
Any |
default = ..., |
|
|
Optional[TextIO] |
stream = None |
|
) |
| |
Shortcut to construct and run a prompt loop and return the result.
Example:
>>> filename = Prompt.ask("Enter a filename")
Args:
prompt (TextType, optional): Prompt text. Defaults to "".
console (Console, optional): A Console instance or None to use global console. Defaults to None.
password (bool, optional): Enable password input. Defaults to False.
choices (List[str], optional): A list of valid choices. Defaults to None.
show_default (bool, optional): Show default in prompt. Defaults to True.
show_choices (bool, optional): Show choices in prompt. Defaults to True.
stream (TextIO, optional): Optional text file open for reading to get input. Defaults to None.