Skip to content

Commit f72f36a

Browse files
authored
Merge pull request #237 from python-cmd2/fix_readme
Fixed the example of transcript testing shown in README.md
2 parents 787cc0a + ec254fd commit f72f36a

File tree

1 file changed

+21
-74
lines changed

1 file changed

+21
-74
lines changed

README.md

Lines changed: 21 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -172,91 +172,38 @@ if __name__ == '__main__':
172172

173173
The following is a sample session running example.py.
174174
Thanks to Cmd2's built-in transcript testing capability, it also serves as a test
175-
suite for example.py when saved as *exampleSession.txt*.
175+
suite for example.py when saved as *transcript_regex.txt*.
176176
Running
177177

178178
```bash
179-
python example.py -t exampleSession.txt
179+
python example.py -t transcript_regex.txt
180180
```
181181
will run all the commands in the transcript against `example.py`, verifying that the output produced
182182
matches the transcript.
183183

184-
example/exampleSession.txt:
184+
example/transcript_regex.txt:
185185

186186
```text
187-
(Cmd) help
188-
189-
Documented commands (type help <topic>):
190-
========================================
191-
_relative_load edit history orate pyscript run say shell show
192-
cmdenvironment help load py quit save set shortcuts speak
193-
194-
(Cmd) help say
195-
Repeats what you tell me to.
196-
Usage: speak [options] arg
197-
198-
Options:
199-
-h, --help show this help message and exit
200-
-p, --piglatin atinLay
201-
-s, --shout N00B EMULATION MODE
202-
-r REPEAT, --repeat=REPEAT
203-
output [n] times
204-
205-
(Cmd) say goodnight, Gracie
206-
goodnight, Gracie
207-
(Cmd) say -ps --repeat=5 goodnight, Gracie
208-
OODNIGHT, GRACIEGAY
209-
OODNIGHT, GRACIEGAY
210-
OODNIGHT, GRACIEGAY
211-
(Cmd) set maxrepeats 5
212-
maxrepeats - was: 3
213-
now: 5
214-
(Cmd) say -ps --repeat=5 goodnight, Gracie
215-
OODNIGHT, GRACIEGAY
216-
OODNIGHT, GRACIEGAY
217-
OODNIGHT, GRACIEGAY
218-
OODNIGHT, GRACIEGAY
219-
OODNIGHT, GRACIEGAY
220-
(Cmd) hi
221-
-------------------------[1]
222-
help
223-
-------------------------[2]
224-
help say
225-
-------------------------[3]
226-
say goodnight, Gracie
227-
-------------------------[4]
228-
say -ps --repeat=5 goodnight, Gracie
229-
-------------------------[5]
230-
set maxrepeats 5
231-
-------------------------[6]
232-
say -ps --repeat=5 goodnight, Gracie
233-
(Cmd) run 4
234-
say -ps --repeat=5 goodnight, Gracie
235-
236-
OODNIGHT, GRACIEGAY
237-
OODNIGHT, GRACIEGAY
238-
OODNIGHT, GRACIEGAY
239-
OODNIGHT, GRACIEGAY
240-
OODNIGHT, GRACIEGAY
241-
(Cmd) orate Four score and
242-
> seven releases ago
243-
> our BDFL
244-
> blah blah blah
245-
Four score and
246-
seven releases ago
247-
our BDFL
248-
blah blah blah
249-
(Cmd) & look, a shortcut!
250-
look, a shortcut!
251-
(Cmd) show color
187+
# Run this transcript with "python example.py -t transcript_regex.txt"
188+
# The regex for colors is because no color on Windows.
189+
# The regex for editor will match whatever program you use.
190+
# regexes on prompts just make the trailing space obvious
191+
(Cmd) set
192+
abbrev: True
193+
autorun_on_edit: False
252194
colors: /(True|False)/
253-
(Cmd) set prompt "---> "
254-
prompt - was: (Cmd)
255-
now: --->
256-
---> say goodbye
257-
goodbye
195+
continuation_prompt: >/ /
196+
debug: False
197+
echo: False
198+
editor: /.*?/
199+
feedback_to_output: False
200+
locals_in_py: True
201+
maxrepeats: 3
202+
prompt: (Cmd)/ /
203+
quiet: False
204+
timing: False
258205
```
259206

260-
Note how a regular expression `/(True|False)/` is used near the end for output of the **show color** command since
207+
Note how a regular expression `/(True|False)/` is used for output of the **show color** command since
261208
colored text is currently not available for cmd2 on Windows. Regular expressions can be used anywhere within a
262209
transcript file simply by embedding them within two forward slashes, `/`.

0 commit comments

Comments
 (0)