summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorTodd Leonhardt <tleonhardt@gmail.com>2017-06-29 12:47:11 -0400
committerTodd Leonhardt <tleonhardt@gmail.com>2017-06-29 12:47:11 -0400
commitd717ea7966574dfec85bcc057f7abe5579c5c121 (patch)
tree6a639c683964eb02f385108ae783a1582a444ecd /README.md
parentd724287da75503c9d5197135d69ee49d8df52e77 (diff)
downloadcmd2-git-d717ea7966574dfec85bcc057f7abe5579c5c121.tar.gz
Refactored to replace custom StubbornDict with collections.OrderedDict
The self.settable object is now an OrderedDict instead of a custom StubbornDict.
Diffstat (limited to 'README.md')
-rwxr-xr-xREADME.md20
1 files changed, 13 insertions, 7 deletions
diff --git a/README.md b/README.md
index 5125eaba..862622f3 100755
--- a/README.md
+++ b/README.md
@@ -103,16 +103,22 @@ Example cmd2 application (**examples/example.py**):
```python
'''A sample application for cmd2.'''
-from cmd2 import Cmd, make_option, options
+from cmd2 import Cmd, make_option, options, set_use_arg_list
class CmdLineApp(Cmd):
- multilineCommands = ['orate']
- Cmd.shortcuts.update({'&': 'speak'})
- maxrepeats = 3
- Cmd.settable.append('maxrepeats')
+ def __init__(self):
+ self.multilineCommands = ['orate']
+ self.maxrepeats = 3
- # Setting this true makes it run a shell command if a cmd2/cmd command doesn't exist
- # default_to_shell = True
+ # Add stuff to settable and shortcutgs before calling base class initializer
+ self.settable['maxrepeats'] = 'max repetitions for speak command'
+ self.shortcuts.update({'&': 'speak'})
+
+ # Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
+ Cmd.__init__(self, use_ipython=False)
+
+ # For option commands, pass a single argument string instead of a list of argument strings to the do_* methods
+ set_use_arg_list(False)
@options([make_option('-p', '--piglatin', action="store_true", help="atinLay"),
make_option('-s', '--shout', action="store_true", help="N00B EMULATION MODE"),