diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-07-03 19:56:25 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-07-03 19:56:25 -0400 |
commit | 7c17d8bbf006e17f0104b6d9d35fc67ca4f235fd (patch) | |
tree | b6112be31428ad363c74a420cda5a70d2bd7f5ac /examples/pirate.py | |
parent | d092e61815f9132b7acd3859563c143ac8ddda56 (diff) | |
download | cmd2-git-7c17d8bbf006e17f0104b6d9d35fc67ca4f235fd.tar.gz |
Fixed a few bugs and examples
Bug fixes:
- case_insensitive is no longer a runtime-settable parameter, but it was still listed as such
- Fixed a recursive loop bug when abbreviated commands are enabled and it could get stuck in the editor forever
- Added additional command abbreviations to the "exclude from history" list
- Fixed argparse_example.py and pirate.py examples
Other changes:
- Organized all attributes used to configure the ParserManager into a single location
- Set the default value of "abbrev" to False (which controls whether or not abbreviated commands are allowed)
- With good tab-completion of command names, using abbreviated commands isn't a particularly useful feature
- And it can create problems
Diffstat (limited to 'examples/pirate.py')
-rwxr-xr-x | examples/pirate.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/examples/pirate.py b/examples/pirate.py index 4fd7e6be..32d7769e 100755 --- a/examples/pirate.py +++ b/examples/pirate.py @@ -11,14 +11,16 @@ from cmd2 import Cmd, options, make_option class Pirate(Cmd): """A piratical example cmd2 application involving looting and drinking.""" - default_to_shell = True - multilineCommands = ['sing'] - terminators = Cmd.terminators + ['...'] - songcolor = 'blue' - settable = Cmd.settable + 'songcolor Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)' - Cmd.shortcuts.update({'~': 'sing'}) - def __init__(self): + self.default_to_shell = True + self.multilineCommands = ['sing'] + self.terminators = Cmd.terminators + ['...'] + self.songcolor = 'blue' + + # Add stuff to settable and/or shortcuts before calling base class initializer + self.settable['songcolor'] = 'Color to ``sing`` in (red/blue/green/cyan/magenta, bold, underline)' + self.shortcuts.update({'~': 'sing'}) + """Initialize the base class as well as this one""" Cmd.__init__(self) # prompts and defaults |