MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / add_alert

Method add_alert

cmd2/cmd2.py:5565–5583  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 3

test_async_alertFunction · 0.80
test_add_alertFunction · 0.80
_add_alerts_funcMethod · 0.80

Calls 2

AsyncAlertClass · 0.85
appendMethod · 0.80

Tested by 2

test_async_alertFunction · 0.64
test_add_alertFunction · 0.64