comparison docs/pycon2010/pycon2010.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 4300ef912f4a
children 49dd1ce6cfd6
comparison
equal deleted inserted replaced
344:4300ef912f4a 345:6fe1e75e3a67
34 34
35 - "Line-oriented command interpreter" 35 - "Line-oriented command interpreter"
36 - "Command-line interface" 36 - "Command-line interface"
37 - "Shell" 37 - "Shell"
38 38
39 * Accepts free text input at prompt 39 1. Accepts free text input at prompt
40 * Outputs lines of text 40 2. Outputs lines of text
41 * Persistent CLI environment 41 3. (repeat)
42 42
43 Examples 43 Examples
44 ======== 44 ========
45 45
46 * Bash, Korn, zsh 46 * Bash, Korn, zsh
53 .. ``ed`` proves that CLI is sometimes the wrong answer. 53 .. ``ed`` proves that CLI is sometimes the wrong answer.
54 54
55 != Command Line Utilities 55 != Command Line Utilities
56 ========================= 56 =========================
57 57
58 * Accept arguments at invocation 58 1. Accepts arguments at invocation
59 * execution 59 2. executes
60 * terminate 60 3. terminates
61 61
62 Examples 62 Examples
63 -------- 63 --------
64 * ls 64 * ls
65 * grep 65 * grep
161 drink [n] - drink [n] barrel[s] o' rum.''' 161 drink [n] - drink [n] barrel[s] o' rum.'''
162 try: 162 try:
163 self.gold -= int(arg) 163 self.gold -= int(arg)
164 except: 164 except:
165 if arg: 165 if arg:
166 print('''What's "{0}"? I'll take rrrum.'''.format(arg)) 166 print('''What's "{0}"? I'll take rrrum.'''
167 .format(arg))
167 self.gold -= 1 168 self.gold -= 1
168 169
169 quitting: pirate5.py 170 quitting: pirate5.py
170 ==================== 171 ====================
171 172
172 :: 173 ::
173 174
174 def postcmd(self, stop, line): 175 def postcmd(self, stop, line):
175 print('Now we gots {0} doubloons'.format(self.gold)) 176 print('Now we gots {0} doubloons'
177 .format(self.gold))
176 if self.gold < 0: 178 if self.gold < 0:
177 print("Off to debtorrr's prrrison. Game overrr.") 179 print("Off to debtorrr's prrrison. Game overrr.")
178 return True 180 return True
179 return stop 181 return stop
180 def do_quit(self, arg): 182 def do_quit(self, arg):
186 188
187 :: 189 ::
188 190
189 prompt = 'arrr> ' 191 prompt = 'arrr> '
190 def default(self, line): 192 def default(self, line):
191 print('What mean ye by "{0}"?'.format(line)) 193 print('What mean ye by "{0}"?'
194 .format(line))
195
196 cmd2
197 ====
198
199 Third-party module in PyPI
200
201 What you get
202 ============
203
204 * Abbreviated commands
205 * Script files
206 * Output redirection
207 * Commands at invocation
208 * Python
209
210 * Searchable command history
211 * Quitting the application
212 * Comments
213 * Misc. pre-defined commands
214 * Transcript-based testing
215 More
216 ====
217
218 * Case-insensitivity
219 * Shortcuts
220 * Default to shell
221 * Timing
222 * Echo
223 * Debug
224 * Other user-settable parameters