11Prompt
22======
33
4- ``cmd2 `` can issue a prompt before soliciting user input.
4+ ``cmd2 `` issues a configurable prompt before soliciting user input.
55
66Customizing the Prompt
77----------------------
88
9- This prompt can be configured by setting the `cmd2.Cmd.prompt ` instance
9+ This prompt can be configured by setting the :attr: `cmd2.Cmd.prompt ` instance
1010attribute. This contains the string which should be printed as a prompt
11- for user input.
11+ for user input. See the Pirate _ example for the simple use case of statically
12+ setting the prompt.
13+
14+ .. _Pirate : https://github.com/python-cmd2/cmd2/blob/master/examples/pirate.py#L33
15+
16+ Continuation Prompt
17+ -------------------
18+
19+ When a user types a
20+ :ref: `Multiline Command <features/multiline_commands:Multiline Commands >`
21+ it may span more than one line of input. The prompt for the first line of input
22+ is specified by the :attr: `cmd2.Cmd.prompt ` instance attribute. The prompt for
23+ subsequent lines of input is defined by the
24+ :attr: `cmd2.Cmd.continuation_prompt ` attribute.See the Initialization _ example
25+ for a demonstration of customizing the continuation prompt.
26+
27+ .. _Initialization : https://github.com/python-cmd2/cmd2/blob/master/examples/initialization.py#L33
28+
29+ Updating the prompt
30+ -------------------
31+
32+ If you wish to update the prompt between commands, you can do so using one of
33+ the :ref: `Application Lifecycle Hooks <features/hooks:Hooks >` such as a
34+ :ref: `Postcommand hook <features/hooks:Postcommand Hooks >`. See
35+ PythonScripting _ for an example of dynamically updating the prompt.
36+
37+ .. _PythonScripting : https://github.com/python-cmd2/cmd2/blob/master/examples/python_scripting.py#L34-L48
1238
1339Asynchronous Feedback
1440---------------------
@@ -20,26 +46,19 @@ functionality, the application must be running in a terminal that supports
2046VT100 control characters and readline. Linux, Mac, and Windows 10 and greater
2147all support these.
2248
23- async_alert()
24- Used to display an important message to the user while they are at the
25- prompt in between commands. To the user it appears as if an alert message
26- is printed above the prompt and their current input text and cursor
27- location is left alone.
49+ .. automethod :: cmd2.Cmd.async_alert
50+ :noindex:
2851
29- async_update_prompt()
30- Updates the prompt while the user is still typing at it. This is good for
31- alerting the user to system changes dynamically in between commands. For
32- instance you could alter the color of the prompt to indicate a system
33- status or increase a counter to report an event.
52+ .. automethod :: cmd2.Cmd.async_update_prompt
53+ :noindex:
3454
3555``cmd2 `` also provides a function to change the title of the terminal window.
3656This feature requires the application be running in a terminal that supports
3757VT100 control characters. Linux, Mac, and Windows 10 and greater all support
3858these.
3959
40- set_window_title()
41- Sets the terminal window title
42-
60+ .. automethod :: cmd2.Cmd.set_window_title
61+ :noindex:
4362
4463The easiest way to understand these functions is to see the AsyncPrinting _
4564example for a demonstration.
0 commit comments