You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> The error message displayed when a non-existent command is run. Default: `{} is not a recognized command, alias, or macro.`
15
-
> :::
16
-
>
17
-
> ::: attribute
18
-
> help[error]{#error}
19
-
>
20
-
> The error message displayed to the user when they request help for a command with no help defined. Default: `No help on {}`
21
-
> :::
22
-
>
23
-
> ::: attribute
24
-
> prompt
25
-
>
26
-
> The prompt issued to solicit input. The default value is `(Cmd)`. See `features/prompt:Prompt`{.interpreted-text role="ref"} for more information.
27
-
> :::
28
-
>
29
-
> ::: attribute
30
-
> continuation[prompt]{#prompt}
31
-
>
32
-
> The prompt issued to solicit input for the 2nd and subsequent lines of a `multiline command <features/multiline_commands:Multiline Commands>`{.interpreted-text role="ref"} Default: `>`.
33
-
> :::
34
-
>
35
-
> ::: attribute
36
-
> echo
37
-
>
38
-
> If `True`, output the prompt and user input before executing the command. When redirecting a series of commands to an output file, this allows you to see the command in the output.
39
-
> :::
40
-
>
41
-
> ::: attribute
42
-
> settable
43
-
>
44
-
> This dictionary contains the name and description of all settings available to users.
45
-
>
46
-
> Users use the `features/builtin_commands:set`{.interpreted-text role="ref"} command to view and modify settings. Settings are stored in instance attributes with the same name as the setting.
47
-
> :::
48
-
>
49
-
> ::: attribute
50
-
> history
51
-
>
52
-
> A record of previously entered commands.
53
-
>
54
-
> This attribute is an instance of `cmd2.history.History`{.interpreted-text role="class"}, and each command is an instance of `cmd2.Statement`{.interpreted-text role="class"}.
55
-
> :::
56
-
>
57
-
> ::: attribute
58
-
> statement[parser]{#parser}
59
-
>
60
-
> An instance of `cmd2.parsing.StatementParser`{.interpreted-text role="class"} initialized and configured appropriately for parsing user input.
61
-
> :::
62
-
>
63
-
> ::: attribute
64
-
> intro
65
-
>
66
-
> Set an introduction message which is displayed to the user before the `features/hooks:Command Processing Loop`{.interpreted-text role="ref"} begins.
67
-
> :::
68
-
>
69
-
> ::: attribute
70
-
> py[bridge_name]{#bridge_name}
71
-
>
72
-
> The symbol name which `features/scripting:Python Scripts`{.interpreted-text role="ref"} run using the `features/builtin_commands:run_pyscript`{.interpreted-text role="ref"} command can use to reference the parent `cmd2` application.
73
-
> :::
74
-
>
75
-
> ::: attribute
76
-
> allow[clipboard]{#clipboard}
77
-
>
78
-
> If `True`, `cmd2` will allow output to be written to or appended to the operating system pasteboard. If `False`, this capability will not be allowed. See `features/clipboard:Clipboard Integration`{.interpreted-text role="ref"} for more information.
79
-
> :::
80
-
>
81
-
> ::: attribute
82
-
> suggest[similar_command]{#similar_command}
83
-
>
84
-
> If `True`, `cmd2` will attempt to suggest the most similar command when the user types a command that does not exist. Default: `False`.
> If you do not supply shortcuts to `cmd2.Cmd.__init__`{.interpreted-text role="meth"}, the shortcuts defined here will be used instead.
12
-
> :::
13
-
>
14
-
> ::: data
15
-
> COMMAND[NAME]{#name}
16
-
>
17
-
> Used by `cmd2.Cmd.disable_command`{.interpreted-text role="meth"} and `cmd2.Cmd.disable_category`{.interpreted-text role="meth"}. Those methods allow you to selectively disable single commands or an entire category of commands. Should you want to include the name of the command in the error message displayed to the user when they try and run a disabled command, you can include this constant in the message where you would like the name of the command to appear. `cmd2` will replace this constant with the name of the command the user tried to run before displaying the error message.
18
-
>
19
-
> This constant is imported into the package namespace; the preferred syntax to import and reference it is:
20
-
>
21
-
> import cmd2
22
-
> errmsg = "The {} command is currently disabled.".format(cmd2.COMMAND_NAME)
23
-
>
24
-
> See `src/examples/help_categories.py` for an example.
Copy file name to clipboardExpand all lines: docs/api/index.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,20 @@ If a release of this library changes any of the items documented here, the versi
10
10
11
11
This documentation is for `cmd2` version {{ version }}.
12
12
13
-
**Modules**
13
+
## Modules
14
14
15
-
-`api/cmd:cmd2.Cmd`{.interpreted-text role="ref"} - functions and attributes of the main class in this library
16
-
-`api/ansi:cmd2.ansi`{.interpreted-text role="ref"} - convenience classes and functions for generating ANSI escape sequences to style text in the terminal
17
-
-`api/argparse_completer:cmd2.argparse_completer`{.interpreted-text role="ref"} - classes for `argparse`-based tab completion
18
-
-`api/argparse_custom:cmd2.argparse_custom`{.interpreted-text role="ref"} - classes and functions for extending `argparse`
19
-
-`api/command_definition:cmd2.command_definition`{.interpreted-text role="ref"} - supports the definition of commands in separate classes to be composed into cmd2.Cmd
20
-
-`api/constants:cmd2.constants`{.interpreted-text role="ref"} - just like it says on the tin
21
-
-`api/decorators:cmd2.decorators`{.interpreted-text role="ref"} - decorators for `cmd2` commands
> The name of the command after shortcuts and macros have been expanded
21
-
> :::
22
-
>
23
-
> ::: attribute
24
-
> args
25
-
>
26
-
> The arguments to the command as a string with spaces between the words, excluding output redirection and command terminators. If the user used quotes in their input, they remain here, and you will have to handle them on your own.
27
-
> :::
28
-
>
29
-
> ::: attribute
30
-
> arg[list]{#list}
31
-
>
32
-
> The arguments to the command as a list, excluding output redirection and command terminators. Each argument is represented as an element in the list. Quoted arguments remain quoted. If you want to remove the quotes, use `cmd2.utils.strip_quotes`{.interpreted-text role="func"} or use `argv[1:]`
33
-
> :::
34
-
>
35
-
> ::: attribute
36
-
> raw
37
-
>
38
-
> If you want full access to exactly what the user typed at the input prompt you can get it, but you'll have to parse it on your own, including:
39
-
>
40
-
> > - shortcuts and aliases
41
-
> > - quoted commands and arguments
42
-
> > - output redirection
43
-
> > - multi-line command terminator handling
44
-
>
45
-
> If you use multiline commands, all the input will be passed to you in this string, but there will be embedded newlines where the user hit return to continue the command on the next line.
46
-
> :::
47
-
>
48
-
> ::: attribute
49
-
> multiline[command]{#command}
50
-
>
51
-
> If the command is a multi-line command, the name of the command will be in this attribute. Otherwise, it will be an empty string.
52
-
> :::
53
-
>
54
-
> ::: attribute
55
-
> terminator
56
-
>
57
-
> If the command is a multi-line command, this attribute contains the termination character entered by the user to signal the end of input
58
-
> :::
59
-
>
60
-
> ::: attribute
61
-
> suffix
62
-
>
63
-
> Any characters present between the input terminator and the output redirection tokens.
64
-
> :::
65
-
>
66
-
> ::: attribute
67
-
> pipe[to]{#to}
68
-
>
69
-
> If the user piped the output to a shell command, this attribute contains the entire shell command as a string. Otherwise it is an empty string.
70
-
> :::
71
-
>
72
-
> ::: attribute
73
-
> output
74
-
>
75
-
> If output was redirected by the user, this contains the redirection token, i.e. `>>`.
76
-
> :::
77
-
>
78
-
> ::: attribute
79
-
> output[to]{#to}
80
-
>
81
-
> If output was redirected by the user, this contains the requested destination with quotes preserved.
0 commit comments