diff options
| author | catherine <catherine@Drou> | 2010-02-16 15:13:11 -0500 |
|---|---|---|
| committer | catherine <catherine@Drou> | 2010-02-16 15:13:11 -0500 |
| commit | fae522ee2ebdf7302f91f52e0c4f3c4dc2c89e0b (patch) | |
| tree | 35d6a494d5e414e41085fcfc1beac5c065760af7 /docs/pycon2010 | |
| parent | c165c534a98a0ae28e92e1d221fffa9c15596d92 (diff) | |
| download | cmd2-hg-fae522ee2ebdf7302f91f52e0c4f3c4dc2c89e0b.tar.gz | |
transcript test wasn't running pre and post cmd hooks
Diffstat (limited to 'docs/pycon2010')
| -rw-r--r-- | docs/pycon2010/pirate6.py | 4 | ||||
| -rw-r--r-- | docs/pycon2010/pycon2010.rst | 51 |
2 files changed, 44 insertions, 11 deletions
diff --git a/docs/pycon2010/pirate6.py b/docs/pycon2010/pirate6.py index 06621c7..7b6e589 100644 --- a/docs/pycon2010/pirate6.py +++ b/docs/pycon2010/pirate6.py @@ -1,4 +1,4 @@ -from cmd import Cmd +from cmd2 import Cmd # prompts and defaults class Pirate(Cmd): @@ -20,7 +20,7 @@ class Pirate(Cmd): print('''What's "{0}"? I'll take rrrum.'''.format(arg)) self.gold -= 1 def postcmd(self, stop, line): - print('Now we gots {0} doubloons'.format(self.gold) + print('Now we gots {0} doubloons'.format(self.gold)) if self.gold < 0: print("Off to debtorrr's prrrison. Game overrr.") return True diff --git a/docs/pycon2010/pycon2010.rst b/docs/pycon2010/pycon2010.rst index 9b71abd..6a886ec 100644 --- a/docs/pycon2010/pycon2010.rst +++ b/docs/pycon2010/pycon2010.rst @@ -36,9 +36,9 @@ Defining - "Command-line interface" - "Shell" -* Accepts free text input at prompt -* Outputs lines of text -* Persistent CLI environment +1. Accepts free text input at prompt +2. Outputs lines of text +3. (repeat) Examples ======== @@ -55,9 +55,9 @@ Examples != Command Line Utilities ========================= -* Accept arguments at invocation -* execution -* terminate +1. Accepts arguments at invocation +2. executes +3. terminates Examples -------- @@ -163,7 +163,8 @@ Arguments: pirate4.py self.gold -= int(arg) except: if arg: - print('''What's "{0}"? I'll take rrrum.'''.format(arg)) + print('''What's "{0}"? I'll take rrrum.''' + .format(arg)) self.gold -= 1 quitting: pirate5.py @@ -172,7 +173,8 @@ quitting: pirate5.py :: def postcmd(self, stop, line): - print('Now we gots {0} doubloons'.format(self.gold)) + print('Now we gots {0} doubloons' + .format(self.gold)) if self.gold < 0: print("Off to debtorrr's prrrison. Game overrr.") return True @@ -188,4 +190,35 @@ prompts and defaults: pirate6.py prompt = 'arrr> ' def default(self, line): - print('What mean ye by "{0}"?'.format(line))
\ No newline at end of file + print('What mean ye by "{0}"?' + .format(line)) + +cmd2 +==== + +Third-party module in PyPI + +What you get +============ + + * Abbreviated commands + * Script files + * Output redirection + * Commands at invocation + * Python + + * Searchable command history + * Quitting the application + * Comments + * Misc. pre-defined commands + * Transcript-based testing +More +==== + + * Case-insensitivity + * Shortcuts + * Default to shell + * Timing + * Echo + * Debug + * Other user-settable parameters |
