Queue an asynchronous alert to be displayed when the prompt is active. Examples: add_alert(msg="System error!") # Print message only add_alert(prompt="user@host> ") # Update prompt only add_alert(msg="Done", prompt="> ") # Update both
(self, *, msg: str | None = None, prompt: str | None = None)
| 5563 | return self.do_run_script(su.quote(relative_path)) |
| 5564 | |
| 5565 | def add_alert(self, *, msg: str | None = None, prompt: str | None = None) -> None: |
| 5566 | """Queue an asynchronous alert to be displayed when the prompt is active. |
| 5567 | |
| 5568 | Examples: |
| 5569 | add_alert(msg="System error!") # Print message only |
| 5570 | add_alert(prompt="user@host> ") # Update prompt only |
| 5571 | add_alert(msg="Done", prompt="> ") # Update both |
| 5572 | |
| 5573 | :param msg: an optional message to be printed above the prompt. |
| 5574 | :param prompt: an optional string to dynamically replace the current prompt. |
| 5575 | |
| 5576 | """ |
| 5577 | if msg is None and prompt is None: |
| 5578 | return |
| 5579 | |
| 5580 | with self._alert_condition: |
| 5581 | alert = AsyncAlert(msg=msg, prompt=prompt) |
| 5582 | self._alert_queue.append(alert) |
| 5583 | self._alert_condition.notify_all() |
| 5584 | |
| 5585 | @staticmethod |
| 5586 | def set_window_title(title: str) -> None: # pragma: no cover |