summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-03-14 21:26:21 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-03-14 21:26:21 -0400
commit8cf0b30af678717160a6c53cc7c0c84aa007c42f (patch)
tree3f15fdd56bc2c740118c8b148d60c745af5b529f
parentcfcff77bf47910e4c5aaaad8fa33f181281f94ee (diff)
downloadcmd2-git-8cf0b30af678717160a6c53cc7c0c84aa007c42f.tar.gz
Updated docs to reflect that shortcuts are now passed into the super class initializer
-rwxr-xr-xREADME.md7
-rw-r--r--docs/settingchanges.rst8
2 files changed, 6 insertions, 9 deletions
diff --git a/README.md b/README.md
index 65a24b8b..1cc045f2 100755
--- a/README.md
+++ b/README.md
@@ -240,12 +240,11 @@ class CmdLineApp(cmd2.Cmd):
def __init__(self):
self.maxrepeats = 3
-
- # Add stuff to shortcuts before calling base class initializer
- self.shortcuts.update({'&': 'speak'})
+ shortcuts = dict(self.DEFAULT_SHORTCUTS)
+ shortcuts.update({'&': 'speak'})
# Set use_ipython to True to enable the "ipy" command which embeds and interactive IPython shell
- super().__init__(use_ipython=False, multiline_commands=['orate'])
+ super().__init__(use_ipython=False, multiline_commands=['orate'], shortcuts=shortcuts)
# Make maxrepeats settable at runtime
self.settable['maxrepeats'] = 'max repetitions for speak command'
diff --git a/docs/settingchanges.rst b/docs/settingchanges.rst
index c9345bc6..b9ad4a22 100644
--- a/docs/settingchanges.rst
+++ b/docs/settingchanges.rst
@@ -33,11 +33,9 @@ To define more shortcuts, update the dict ``App.shortcuts`` with the
class App(Cmd2):
def __init__(self):
- # Make sure you update the shortcuts attribute before calling the super class __init__
- self.shortcuts.update({'*': 'sneeze', '~': 'squirm'})
-
- # Make sure to call this super class __init__ after updating shortcuts
- cmd2.Cmd.__init__(self)
+ shortcuts = dict(self.DEFAULT_SHORTCUTS)
+ shortcuts.update({'*': 'sneeze', '~': 'squirm'})
+ cmd2.Cmd.__init__(self, shortcuts=shortcuts)
.. warning::