annotate docs/settingchanges.rst @ 337:2ce34ad4e520

begin Pycon talk
author catherine@Drou
date Tue, 16 Feb 2010 11:02:56 -0500
parents 6306edc46a6e
children 92a15405ed8a
rev   line source
315
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
1 =========================================
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
2 Features requiring only parameter changes
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
3 =========================================
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
4
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
5 Several aspects of a ``cmd2`` application's behavior
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
6 can be controlled simply by setting attributes of ``App``.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
7
328
7b2bca3951a7 locals_in_py
cat@eee
parents: 325
diff changeset
8 (To define your own user-settable parameters, see :ref:`parameters`)
315
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
9
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
10 Case-insensitivity
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
11 ==================
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
12
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
13 By default, all ``cmd2`` command names are case-insensitive;
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
14 ``sing the blues`` and ``SiNg the blues`` are equivalent. To change this,
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
15 set ``App.case_insensitive`` to False.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
16
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
17 Whether or not you set ``case_insensitive``, *please do not* define
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
18 command method names with any uppercase letters. ``cmd2`` will probably
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
19 do something evil if you do.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
20
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
21 Multiline commands
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
22 ==================
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
23
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
24 Like cmd_, ``cmd2`` assumes that a line break ends any command.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
25 However, ``App.multilineCommands`` is a list of commands that are assumed to span
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
26 multiple lines. For these commands
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
27
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
28 ``cmd2.Cmd.multilineCommands`` defaults to [], so you may set your own list
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
29 of multiline command names (without ``do_``)::
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
30
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
31 class App(Cmd):
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
32 multilineCommands = ['lenghtycommand']
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
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
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
35
331
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
36
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
37 Shortcuts
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
38 =========
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
39
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
40 Special-character shortcuts for common commands can make life more convenient for your
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
41 users. Shortcuts are used without a space separating them from their arguments,
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
42 like ``!ls``. By default, the following shortcuts are defined:
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
43
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
44 ``?``
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
45 help
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
46
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
47 ``!``
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
48 shell: run as OS-level command
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
49
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
50 ``@``
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
51 load script file
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
52
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
53 ``@@``
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
54 load script file; filename is relative to current script location
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
55
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
56 To define more shortcuts, update the dict ``App.shortcuts`` with the
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
57 {'shortcut': 'command_name'} (omit ``do_``)::
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
58
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
59 class App(Cmd2):
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
60 Cmd2.shortcuts.update({'*': 'sneeze', '~': 'squirm'})
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
61
331
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
62 Default to shell
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
63 ================
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
64
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
65 Every ``cmd2`` application can execute operating-system
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
66 level (shell) commands with ``shell`` or a ``!``
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
67 shortcut::
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
68
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
69 (Cmd) shell which python
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
70 /usr/bin/python
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
71 (Cmd) !which python
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
72 /usr/bin/python
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
73
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
74 However, if the parameter ``default_to_shell`` is
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
75 ``True``, then *every* command will be attempted on
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
76 the operating system. Only if that attempt fails
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
77 (i.e., produces a nonzero return value) will the
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
78 application's own ``default`` method be called.
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
79
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
80 ::
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
81
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
82 (Cmd) which python
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
83 /usr/bin/python
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
84 (Cmd) my dog has fleas
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
85 sh: my: not found
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
86 *** Unknown syntax: my dog has fleas
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
87
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
88 Timing
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
89 ======
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
90
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
91 Setting ``App.timing`` to ``True`` outputs timing data after
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
92 every application command is executed. |settable|
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
93
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
94 Debug
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
95 =====
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
96
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
97 Setting ``App.debug`` to ``True`` will produce detailed error stacks
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
98 whenever the application generates an error. |settable|
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
99
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
100 .. |settable| replace:: The user can ``set`` this parameter
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
101 during application execution.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
102 (See :ref:`parameters`)
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
103
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
104 Settability
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
105 ===========
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
106
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
107 If you wish the user to be able to set one of these
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
108 application-controlling attributes while the application
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
109 is running, add its name to ``App.settable``. See
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
110 :ref:`parameters`.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 315
diff changeset
111
331
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
112 Other user-settable parameters
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
113 ==============================
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
114
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
115 A list of all user-settable parameters, with brief
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
116 comments, is viewable from within a running application
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
117 with::
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
118
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
119 (Cmd) set --long
6306edc46a6e more docs
cat@eee
parents: 328
diff changeset
120