From d717ea7966574dfec85bcc057f7abe5579c5c121 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Thu, 29 Jun 2017 12:47:11 -0400 Subject: Refactored to replace custom StubbornDict with collections.OrderedDict The self.settable object is now an OrderedDict instead of a custom StubbornDict. --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'README.md') 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"), -- cgit v1.2.1