Debian Codegraph @

docs/features/multiline_commands.md

raw symbols SCIP
1 # Multiline Commands
2
3 Command input may span multiple lines for the commands whose names are listed in the
4 `multiline_commands` argument to [cmd2.Cmd.\_\_init\_\_][cmd2.Cmd.__init__]. These commands will be
5 executed only after the user has entered a _terminator_. By default, the command terminator is `;`.
6 Specifying the `terminators` optional argument to `cmd2.Cmd.__init__()` allows different
7 terminators. A blank line is _always_ considered a command terminator (cannot be overridden).
8
9 In multiline commands, output redirection characters like `>` and `|` are part of the command
10 arguments unless they appear after the terminator.
11
12 ## Continuation prompt
13
14 When a user types a **Multiline Command** it may span more than one line of input. The prompt for
15 the first line of input is specified by the [cmd2.Cmd.prompt][] instance attribute - see
16 [Customizing the Prompt](./prompt.md#customizing-the-prompt). The prompt for subsequent lines of
17 input is defined by the [cmd2.Cmd.continuation_prompt][] attribute.
18
19 ## Use cases
20
21 Multiline commands should probably be used sparingly in order to preserve a good user experience for
22 your `cmd2`-based line-oriented command interpreter application.
23
24 However, some use cases benefit significantly from the ability to have commands that span more than
25 one line. For example, you might want the ability for your user to type in a SQL command, which can
26 often span lines and which are terminated with a semicolon.
27
28 We estimate that less than 5 percent of `cmd2` applications use this feature. But it is here for
29 those use cases where it provides value.