comparison docs/freefeatures.rst @ 345:6fe1e75e3a67

transcript test wasn't running pre and post cmd hooks
author catherine@Drou
date Tue, 16 Feb 2010 15:13:11 -0500
parents 49bea7cab179
children 49dd1ce6cfd6
comparison
equal deleted inserted replaced
344:4300ef912f4a 345:6fe1e75e3a67
2 Features requiring no modifications 2 Features requiring no modifications
3 =================================== 3 ===================================
4 4
5 These features are provided "for free" to a cmd_-based application 5 These features are provided "for free" to a cmd_-based application
6 simply by replacing ``import cmd`` with ``import cmd2 as cmd``. 6 simply by replacing ``import cmd`` with ``import cmd2 as cmd``.
7
8 Abbreviated commands
9 ====================
10
11 ``cmd2`` apps will accept shortened command names
12 so long as there is no ambiguity. Thus, if
13 ``do_divide`` is defined, then ``divid``, ``div``,
14 or even ``d`` will suffice, so long as there are
15 no other commands defined beginning with *divid*,
16 *div*, or *d*.
17
18 This behavior can be turned off with ``app.abbrev`` (see :ref:`parameters`)
19 7
20 Script files 8 Script files
21 ============ 9 ============
22 10
23 Text files can serve as scripts for your ``cmd2``-based 11 Text files can serve as scripts for your ``cmd2``-based
27 .. automethod:: cmd2.Cmd.do_load 15 .. automethod:: cmd2.Cmd.do_load
28 16
29 .. automethod:: cmd2.Cmd.do_save 17 .. automethod:: cmd2.Cmd.do_save
30 18
31 .. automethod:: cmd2.Cmd.do_edit 19 .. automethod:: cmd2.Cmd.do_edit
20
21 Comments
22 ========
23
24 Comments are omitted from the argument list
25 before it is passed to a ``do_`` method. By
26 default, both Python-style and C-style comments
27 are recognized; you may change this by overriding
28 ``app.commentGrammars`` with a different pyparsing_
29 grammar.
30
31 Comments can be useful in :ref:`script`s. Used
32 in an interactive session, they may indicate
33 mental imbalance.
34
35 ::
36
37 def do_speak(self, arg):
38 self.stdout.write(arg + '\n')
39
40 ::
41
42 (Cmd) speak it was /* not */ delicious! # Yuck!
43 it was delicious!
32 44
33 Output redirection 45 Output redirection
34 ================== 46 ==================
35 47
36 As in a Unix shell, output of a command can be redirected: 48 As in a Unix shell, output of a command can be redirected:
126 138
127 ``cmd2`` pre-defines a ``quit`` command for you (with 139 ``cmd2`` pre-defines a ``quit`` command for you (with
128 synonyms ``exit`` and simply ``q``). 140 synonyms ``exit`` and simply ``q``).
129 It's trivial, but it's one less thing for you to remember. 141 It's trivial, but it's one less thing for you to remember.
130 142
131 Comments
132 ========
133 143
134 Comments are omitted from the argument list 144 Abbreviated commands
135 before it is passed to a ``do_`` method. By 145 ====================
136 default, both Python-style and C-style comments
137 are recognized; you may change this by overriding
138 ``app.commentGrammars`` with a different pyparsing_
139 grammar.
140 146
141 Comments can be useful in :ref:`script`s. Used 147 ``cmd2`` apps will accept shortened command names
142 in an interactive session, they may indicate 148 so long as there is no ambiguity. Thus, if
143 mental imbalance. 149 ``do_divide`` is defined, then ``divid``, ``div``,
150 or even ``d`` will suffice, so long as there are
151 no other commands defined beginning with *divid*,
152 *div*, or *d*.
144 153
145 :: 154 This behavior can be turned off with ``app.abbrev`` (see :ref:`parameters`)
146 155
147 def do_speak(self, arg):
148 self.stdout.write(arg + '\n')
149
150 ::
151
152 (Cmd) speak it was /* not */ delicious! # Yuck!
153 it was delicious!
154
155 Misc. pre-defined commands 156 Misc. pre-defined commands
156 ========================== 157 ==========================
157 158
158 Several generically useful commands are defined 159 Several generically useful commands are defined
159 with automatically included ``do_`` methods. 160 with automatically included ``do_`` methods.
168 is equivalent to ``shell ls``.) 169 is equivalent to ``shell ls``.)
169 170
170 171
171 Transcript-based testing 172 Transcript-based testing
172 ======================== 173 ========================
174
175 If a ``cmd2``-based application is invoked with --test