annotate docs/unfreefeatures.rst @ 411:9d5ff2ddfdea 0.6.2

doc update
author Catherine Devlin <catherine.devlin@gmail.com>
date Tue, 09 Nov 2010 05:22:41 -0500
parents 52ab96d4f179
children f16f444a4d10
rev   line source
315
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
1 ======================================
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
2 Features requiring application changes
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
3 ======================================
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
4
331
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
5 Multiline commands
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
6 ==================
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
7
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
8 Command input may span multiple lines for the
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
9 commands whose names are listed in the
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
10 parameter ``app.multilineCommands``. These
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
11 commands will be executed only
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
12 after the user has entered a *terminator*.
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
13 By default, the command terminators is
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
14 ``;``; replacing or appending to the list
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
15 ``app.terminators`` allows different
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
16 terminators. A blank line
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
17 is *always* considered a command terminator
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
18 (cannot be overridden).
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
19
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
20 Parsed statements
315
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
21 =================
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
22
331
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
23 ``cmd2`` passes ``arg`` to a ``do_`` method (or
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
24 ``default`) as a ParsedString, a subclass of
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
25 string that includes an attribute ``parsed``.
388
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
26 ``parsed`` is a ``pyparsing.ParseResults``
331
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
27 object produced by applying a pyparsing_
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
28 grammar applied to ``arg``. It may include:
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
29
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
30 command
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
31 Name of the command called
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
32
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
33 raw
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
34 Full input exactly as typed.
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
35
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
36 terminator
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
37 Character used to end a multiline command
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
38
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
39 suffix
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
40 Remnant of input after terminator
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
41
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
42 ::
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
43
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
44 def do_parsereport(self, arg):
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
45 self.stdout.write(arg.parsed.dump() + '\n')
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
46
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
47 ::
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
48
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
49 (Cmd) parsereport A B /* C */ D; E
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
50 ['parsereport', 'A B D', ';', 'E']
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
51 - args: A B D
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
52 - command: parsereport
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
53 - raw: parsereport A B /* C */ D; E
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
54 - statement: ['parsereport', 'A B D', ';']
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
55 - args: A B D
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
56 - command: parsereport
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
57 - terminator: ;
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
58 - suffix: E
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
59 - terminator: ;
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
60
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
61 If ``parsed`` does not contain an attribute,
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
62 querying for it will return ``None``. (This
388
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
63 is a characteristic of ``pyparsing.ParseResults``.)
331
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
64
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
65 ParsedString was developed to support sqlpython_
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
66 and reflects its needs. The parsing grammar and
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
67 process are painfully complex and should not be
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
68 considered stable; future ``cmd2`` releases may
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
69 change it somewhat (hopefully reducing complexity).
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
70
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
71 (Getting ``arg`` as a ``ParsedString`` is
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
72 technically "free", in that it requires no application
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
73 changes from the cmd_ standard, but there will
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
74 be no result unless you change your application
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
75 to *use* ``arg.parsed``.)
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
76
388
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
77 .. _sqlpython: http://pypi.python.org/pypi/sqlpython/
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
78
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
79 .. _cmd: http://docs.python.org/library/cmd.html#module-cmd
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
80
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
81 .. _pyparsing: http://pyparsing.wikispaces.com/
52ab96d4f179 fix some Sphinx warnings
anatoly techtonik <techtonik@gmail.com>
parents: 336
diff changeset
82
315
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
83 Environment parameters
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
84 ======================
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
85
316
8a76f597d2f9 oops, remove benchmark references
cat@eee
parents: 315
diff changeset
86 Your application can define user-settable parameters
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
87 which your code can reference. Create them as class attributes
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
88 with their default values, and add them (with optional
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
89 documentation) to ``settable``.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
90
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
91 ::
316
8a76f597d2f9 oops, remove benchmark references
cat@eee
parents: 315
diff changeset
92
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
93 from cmd2 import Cmd
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
94 class App(Cmd):
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
95 degrees_c = 22
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
96 sunny = False
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
97 settable = Cmd.settable + '''degrees_c temperature in Celsius
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
98 sunny'''
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
99 def do_sunbathe(self, arg):
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
100 if self.degrees_c < 20:
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
101 result = "It's {temp} C - are you a penguin?".format(temp=self.degrees_c)
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
102 elif not self.sunny:
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
103 result = 'Too dim.'
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
104 else:
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
105 result = 'UV is bad for your skin.'
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
106 self.stdout.write(result + '\n')
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
107 app = App()
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
108 app.cmdloop()
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
109
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
110 ::
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
111
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
112 (Cmd) set --long
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
113 degrees_c: 22 # temperature in Celsius
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
114 sunny: False #
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
115 (Cmd) sunbathe
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
116 Too dim.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
117 (Cmd) set sunny yes
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
118 sunny - was: False
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
119 now: True
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
120 (Cmd) sunbathe
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
121 UV is bad for your skin.
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
122 (Cmd) set degrees_c 13
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
123 degrees_c - was: 22
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
124 now: 13
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
125 (Cmd) sunbathe
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
126 It's 13 C - are you a penguin?
316
8a76f597d2f9 oops, remove benchmark references
cat@eee
parents: 315
diff changeset
127
8a76f597d2f9 oops, remove benchmark references
cat@eee
parents: 315
diff changeset
128
315
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
129 Commands with flags
a08c50b7d3d3 doc skeleton
cat@eee
parents:
diff changeset
130 ===================
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
131
331
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
132 All ``do_`` methods are responsible for interpreting
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
133 the arguments passed to them. However, ``cmd2`` lets
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
134 a ``do_`` methods accept Unix-style *flags*. It uses optparse_
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
135 to parse the flags, and they work the same way as for
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
136 that module.
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
137
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
138 Flags are defined with the ``options`` decorator,
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
139 which is passed a list of optparse_-style options,
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
140 each created with ``make_option``. The method
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
141 should accept a second argument, ``opts``, in
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
142 addition to ``args``; the flags will be stripped
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
143 from ``args``.
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
144
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
145 ::
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
146
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
147 @options([make_option('-p', '--piglatin', action="store_true", help="atinLay"),
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
148 make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"),
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
149 make_option('-r', '--repeat', type="int", help="output [n] times")
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
150 ])
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
151 def do_speak(self, arg, opts=None):
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
152 """Repeats what you tell me to."""
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
153 arg = ''.join(arg)
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
154 if opts.piglatin:
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
155 arg = '%s%say' % (arg[1:].rstrip(), arg[0])
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
156 if opts.shout:
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
157 arg = arg.upper()
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
158 repetitions = opts.repeat or 1
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
159 for i in range(min(repetitions, self.maxrepeats)):
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
160 self.stdout.write(arg)
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
161 self.stdout.write('\n')
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
162
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
163 ::
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
164
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
165 (Cmd) say goodnight, gracie
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
166 goodnight, gracie
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
167 (Cmd) say -sp goodnight, gracie
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
168 OODNIGHT, GRACIEGAY
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
169 (Cmd) say -r 2 --shout goodnight, gracie
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
170 GOODNIGHT, GRACIE
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
171 GOODNIGHT, GRACIE
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
172
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
173 .. _optparse:
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
174
324
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
175 .. _outputters:
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
176
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
177 poutput, pfeedback, perror
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
178 ==========================
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
179
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
180 Standard ``cmd`` applications produce their output with ``self.stdout.write('output')`` (or with ``print``,
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
181 but ``print`` decreases output flexibility). ``cmd2`` applications can use
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
182 ``self.poutput('output')``, ``self.pfeedback('message')``, and ``self.perror('errmsg')``
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
183 instead. These methods have these advantages:
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
184
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
185 - More concise
21584174d865 make SHOW TABLES work
catherine@dellzilla
parents: 316
diff changeset
186 - ``.pfeedback()`` destination is controlled by :ref:`quiet` parameter.
411
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
187
336
8aa71e8f1064 alternatives
catherine@Drou
parents: 333
diff changeset
188 color
8aa71e8f1064 alternatives
catherine@Drou
parents: 333
diff changeset
189 =====
8aa71e8f1064 alternatives
catherine@Drou
parents: 333
diff changeset
190
411
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
191 Text output can be colored by wrapping it in the ``colorize`` method.
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
192
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
193 .. automethod:: cmd2.Cmd.colorize
336
8aa71e8f1064 alternatives
catherine@Drou
parents: 333
diff changeset
194
411
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
195 .. _quiet:
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
196
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
197 quiet
331
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
198 =====
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
199
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
200 Controls whether ``self.pfeedback('message')`` output is suppressed;
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
201 useful for non-essential feedback that the user may not always want
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
202 to read. ``quiet`` is only relevant if
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
203 ``app.pfeedback`` is sometimes used.
6306edc46a6e more docs
cat@eee
parents: 324
diff changeset
204
332
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
205 ``select``
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
206 ==========
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
207
411
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
208 Presents numbered options to user, as bash ``select``.
9d5ff2ddfdea doc update
Catherine Devlin <catherine.devlin@gmail.com>
parents: 388
diff changeset
209
332
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
210 ``app.select`` is called from within a method (not by the user directly; it is ``app.select``, not ``app.do_select``).
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
211
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
212 .. automethod:: cmd2.Cmd.select
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
213
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
214 ::
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
215
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
216 def do_eat(self, arg):
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
217 sauce = self.select('sweet salty', 'Sauce? ')
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
218 result = '{food} with {sauce} sauce, yum!'
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
219 result = result.format(food=arg, sauce=sauce)
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
220 self.stdout.write(result + '\n')
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
221
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
222 ::
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
223
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
224 (Cmd) eat wheaties
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
225 1. sweet
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
226 2. salty
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
227 Sauce? 2
49bea7cab179 doc refreshing refresh.bash
cat@eee
parents: 331
diff changeset
228 wheaties with salty sauce, yum!