Mercurial > python-cmd2
annotate docs/settingchanges.rst @ 325:4172feeddf76
want to incorporate run() for tests - not yet working
author | catherine@dellzilla |
---|---|
date | Thu, 11 Feb 2010 17:03:45 -0500 |
parents | 21584174d865 |
children | 7b2bca3951a7 |
rev | line source |
---|---|
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``. | |
7 | |
8 (To define your own user-settable parameters, see :ref:`parameters` | |
315 | 9 |
10 Case-insensitivity | |
11 ================== | |
12 | |
324 | 13 By default, all ``cmd2`` command names are case-insensitive; |
14 ``sing the blues`` and ``SiNg the blues`` are equivalent. To change this, | |
15 set ``App.case_insensitive`` to False. | |
16 | |
17 Whether or not you set ``case_insensitive``, *please do not* define | |
18 command method names with any uppercase letters. ``cmd2`` will probably | |
19 do something evil if you do. | |
20 | |
21 Multiline commands | |
22 ================== | |
23 | |
24 Like cmd_, ``cmd2`` assumes that a line break ends any command. | |
25 However, ``App.multilineCommands`` is a list of commands that are assumed to span | |
26 multiple lines. For these commands | |
27 | |
28 ``cmd2.Cmd.multilineCommands`` defaults to [], so you may set your own list | |
29 of multiline command names (without ``do_``):: | |
30 | |
31 class App(Cmd): | |
32 multilineCommands = ['lenghtycommand'] | |
33 def do_lengthycommand(self, args): | |
325
4172feeddf76
want to incorporate run() for tests - not yet working
catherine@dellzilla
parents:
324
diff
changeset
|
34 # ... |
324 | 35 |
36 Shortcuts | |
37 ========= | |
38 | |
39 Special-character shortcuts for common commands can make life more convenient for your | |
40 users. Shortcuts are used without a space separating them from their arguments, | |
41 like ``!ls``. By default, the following shortcuts are defined: | |
42 | |
43 ``?`` | |
44 help | |
45 | |
46 ``!`` | |
47 shell: run as OS-level command | |
48 | |
49 ``@`` | |
50 load script file | |
51 | |
52 ``@@`` | |
53 load script file; filename is relative to current script location | |
54 | |
55 To define more shortcuts, update the dict ``App.shortcuts`` with the | |
56 {'shortcut': 'command_name'} (omit ``do_``):: | |
57 | |
58 class App(Cmd2): | |
59 Cmd2.shortcuts.update({'*': 'sneeze', '~': 'squirm'}) | |
60 | |
61 Timing | |
62 ====== | |
63 | |
64 Setting ``App.timing`` to ``True`` outputs timing data after | |
65 every application command is executed. |settable| | |
66 | |
67 Debug | |
68 ===== | |
69 | |
70 Setting ``App.debug`` to ``True`` will produce detailed error stacks | |
71 whenever the application generates an error. |settable| | |
72 | |
73 .. |settable| replace:: The user can ``set`` this parameter | |
74 during application execution. | |
75 (See :ref:`parameters`) | |
76 | |
77 .. _quiet: | |
78 | |
79 Quiet | |
80 ===== | |
81 | |
82 Controls whether ``self.pfeedback('message')`` output is suppressed; | |
83 useful for non-essential feedback that the user may not always want | |
84 to read. Only relevant if :ref:`outputters` are used. | |
85 | |
86 Settability | |
87 =========== | |
88 | |
89 If you wish the user to be able to set one of these | |
90 application-controlling attributes while the application | |
91 is running, add its name to ``App.settable``. See | |
92 :ref:`parameters`. | |
93 | |
315 | 94 Abbreviated commands |
95 ==================== |