Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions InquirerPy/prompts/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ class CheckboxPrompt(ListPrompt):
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
erase_when_done: Clear the rendered prompt from the terminal after the application exits.
Useful when looping over multiple prompt instances (e.g. a refresh loop) to avoid
leaving ghost output from previous iterations on screen.

Examples:
>>> from InquirerPy import inquirer
Expand Down Expand Up @@ -194,6 +197,7 @@ def __init__(
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
session_result: Optional[InquirerPySessionResult] = None,
erase_when_done: bool = False,
) -> None:
self.content_control = InquirerPyCheckboxControl(
choices=choices,
Expand Down Expand Up @@ -228,6 +232,7 @@ def __init__(
mandatory=mandatory,
mandatory_message=mandatory_message,
session_result=session_result,
erase_when_done=erase_when_done,
)

def _handle_enter(self, event) -> None:
Expand Down
5 changes: 5 additions & 0 deletions InquirerPy/prompts/expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ class ExpandPrompt(ListPrompt):
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
erase_when_done: Clear the rendered prompt from the terminal after the application exits.
Useful when looping over multiple prompt instances (e.g. a refresh loop) to avoid
leaving ghost output from previous iterations on screen.

Examples:
>>> from InquirerPy import inquirer
Expand Down Expand Up @@ -304,6 +307,7 @@ def __init__(
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
session_result: Optional[InquirerPySessionResult] = None,
erase_when_done: bool = False,
) -> None:
if expand_help is None:
expand_help = ExpandHelp(message=help_msg)
Expand Down Expand Up @@ -345,6 +349,7 @@ def __init__(
mandatory=mandatory,
mandatory_message=mandatory_message,
session_result=session_result,
erase_when_done=erase_when_done,
)

def _on_rendered(self, _) -> None:
Expand Down
6 changes: 6 additions & 0 deletions InquirerPy/prompts/fuzzy.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ class FuzzyPrompt(BaseListPrompt):
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
erase_when_done: Clear the rendered prompt from the terminal after the application exits.
Useful when looping over multiple prompt instances (e.g. a refresh loop) to avoid
leaving ghost output from previous iterations on screen.

Examples:
>>> from InquirerPy import inquirer
Expand Down Expand Up @@ -366,6 +369,7 @@ def __init__(
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
session_result: Optional[InquirerPySessionResult] = None,
erase_when_done: bool = False,
) -> None:
if not keybindings:
keybindings = {}
Expand All @@ -374,6 +378,7 @@ def __init__(
self._task = None
self._rendered = False
self._exact_symbol = exact_symbol
self._erase_when_done = erase_when_done

keybindings = {
"up": [{"key": "up"}, {"key": "c-p"}],
Expand Down Expand Up @@ -498,6 +503,7 @@ def __init__(
key_bindings=self._kb,
editing_mode=self._editing_mode,
after_render=self._after_render,
erase_when_done=self._erase_when_done,
)

def _toggle_exact(self, _, value: Optional[bool] = None) -> None:
Expand Down
6 changes: 6 additions & 0 deletions InquirerPy/prompts/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ class ListPrompt(BaseListPrompt):
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
erase_when_done: Clear the rendered prompt from the terminal after the application exits.
Useful when looping over multiple prompt instances (e.g. a refresh loop) to avoid
leaving ghost output from previous iterations on screen.

Examples:
>>> from InquirerPy import inquirer
Expand Down Expand Up @@ -192,6 +195,7 @@ def __init__(
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
session_result: Optional[InquirerPySessionResult] = None,
erase_when_done: bool = False,
) -> None:
if not hasattr(self, "_content_control"):
self.content_control = InquirerPyListControl(
Expand Down Expand Up @@ -226,6 +230,7 @@ def __init__(
session_result=session_result,
)
self._show_cursor = show_cursor
self._erase_when_done = erase_when_done
self._dimmension_height, self._dimmension_max_height = calculate_height(
height, max_height, height_offset=self.height_offset
)
Expand Down Expand Up @@ -282,6 +287,7 @@ def __init__(
style=self._style,
key_bindings=self._kb,
after_render=self._after_render,
erase_when_done=self._erase_when_done,
)

def _get_prompt_message_with_cursor(self) -> List[Tuple[str, str]]:
Expand Down
6 changes: 6 additions & 0 deletions InquirerPy/prompts/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class NumberPrompt(BaseComplexPrompt):
mandatory: Indicate if the prompt is mandatory. If True, then the question cannot be skipped.
mandatory_message: Error message to show when user attempts to skip mandatory prompt.
session_result: Used internally for :ref:`index:Classic Syntax (PyInquirer)`.
erase_when_done: Clear the rendered prompt from the terminal after the application exits.
Useful when looping over multiple prompt instances (e.g. a refresh loop) to avoid
leaving ghost output from previous iterations on screen.

Examples:
>>> from InquirerPy import inquirer
Expand Down Expand Up @@ -128,6 +131,7 @@ def __init__(
mandatory: bool = True,
mandatory_message: str = "Mandatory prompt",
session_result: Optional[InquirerPySessionResult] = None,
erase_when_done: bool = False,
) -> None:
super().__init__(
message=message,
Expand Down Expand Up @@ -157,6 +161,7 @@ def __init__(
self._whole_replace = False
self._integral_replace = False
self._replace_mode = replace_mode
self._erase_when_done = erase_when_done

self._leading_zero_pattern = re.compile(r"^(0*)[0-9]+.*")
self._sn_pattern = re.compile(r"^.*E-.*")
Expand Down Expand Up @@ -329,6 +334,7 @@ def _(_):
key_bindings=self._kb,
after_render=self._after_render,
editing_mode=self._editing_mode,
erase_when_done=self._erase_when_done,
)

def _fix_sn(self, value: str) -> Tuple[str, str]:
Expand Down
Loading