315
|
1 =========================================
|
|
2 Features requiring only parameter changes
|
|
3 =========================================
|
|
4
|
324
|
5 Several aspects of a ``cmd2`` application's behavior
|
|
6 can be controlled simply by setting attributes of ``App``.
|
338
|
7 A parameter can also be changed at runtime by the user *if*
|
|
8 its name is included in the dictionary ``app.settable``.
|
328
|
9 (To define your own user-settable parameters, see :ref:`parameters`)
|
315
|
10
|
|
11 Case-insensitivity
|
|
12 ==================
|
|
13
|
324
|
14 By default, all ``cmd2`` command names are case-insensitive;
|
|
15 ``sing the blues`` and ``SiNg the blues`` are equivalent. To change this,
|
|
16 set ``App.case_insensitive`` to False.
|
|
17
|
|
18 Whether or not you set ``case_insensitive``, *please do not* define
|
|
19 command method names with any uppercase letters. ``cmd2`` will probably
|
|
20 do something evil if you do.
|
331
|
21
|
324
|
22 Shortcuts
|
|
23 =========
|
|
24
|
|
25 Special-character shortcuts for common commands can make life more convenient for your
|
|
26 users. Shortcuts are used without a space separating them from their arguments,
|
|
27 like ``!ls``. By default, the following shortcuts are defined:
|
|
28
|
|
29 ``?``
|
|
30 help
|
|
31
|
|
32 ``!``
|
|
33 shell: run as OS-level command
|
|
34
|
|
35 ``@``
|
|
36 load script file
|
|
37
|
|
38 ``@@``
|
|
39 load script file; filename is relative to current script location
|
|
40
|
|
41 To define more shortcuts, update the dict ``App.shortcuts`` with the
|
|
42 {'shortcut': 'command_name'} (omit ``do_``)::
|
|
43
|
|
44 class App(Cmd2):
|
|
45 Cmd2.shortcuts.update({'*': 'sneeze', '~': 'squirm'})
|
|
46
|
331
|
47 Default to shell
|
|
48 ================
|
|
49
|
|
50 Every ``cmd2`` application can execute operating-system
|
|
51 level (shell) commands with ``shell`` or a ``!``
|
|
52 shortcut::
|
|
53
|
|
54 (Cmd) shell which python
|
|
55 /usr/bin/python
|
|
56 (Cmd) !which python
|
|
57 /usr/bin/python
|
|
58
|
|
59 However, if the parameter ``default_to_shell`` is
|
|
60 ``True``, then *every* command will be attempted on
|
|
61 the operating system. Only if that attempt fails
|
|
62 (i.e., produces a nonzero return value) will the
|
|
63 application's own ``default`` method be called.
|
|
64
|
|
65 ::
|
|
66
|
|
67 (Cmd) which python
|
|
68 /usr/bin/python
|
|
69 (Cmd) my dog has fleas
|
|
70 sh: my: not found
|
|
71 *** Unknown syntax: my dog has fleas
|
|
72
|
324
|
73 Timing
|
|
74 ======
|
|
75
|
|
76 Setting ``App.timing`` to ``True`` outputs timing data after
|
|
77 every application command is executed. |settable|
|
|
78
|
338
|
79 Echo
|
|
80 ====
|
|
81
|
|
82 If ``True``, each command the user issues will be repeated
|
|
83 to the screen before it is executed. This is particularly
|
|
84 useful when running scripts.
|
|
85
|
324
|
86 Debug
|
|
87 =====
|
|
88
|
|
89 Setting ``App.debug`` to ``True`` will produce detailed error stacks
|
|
90 whenever the application generates an error. |settable|
|
|
91
|
|
92 .. |settable| replace:: The user can ``set`` this parameter
|
|
93 during application execution.
|
|
94 (See :ref:`parameters`)
|
|
95
|
|
96
|
331
|
97 Other user-settable parameters
|
|
98 ==============================
|
|
99
|
|
100 A list of all user-settable parameters, with brief
|
|
101 comments, is viewable from within a running application
|
|
102 with::
|
|
103
|
|
104 (Cmd) set --long
|
338
|
105 abbrev: True # Accept abbreviated commands
|
|
106 case_insensitive: True # upper- and lower-case both OK
|
|
107 colors: True # Colorized output (*nix only)
|
|
108 continuation_prompt: > # On 2nd+ line of input
|
|
109 debug: False # Show full error stack on error
|
|
110 default_file_name: command.txt # for ``save``, ``load``, etc.
|
|
111 echo: False # Echo command issued into output
|
|
112 editor: gedit # Program used by ``edit``
|
|
113 feedback_to_output: False # include nonessentials in `|`, `>` results
|
|
114 prompt: (Cmd) #
|
|
115 quiet: False # Don't print nonessential feedback
|
|
116 timing: False # Report execution times
|
|
117
|
331
|
118
|