@@ -19,11 +19,11 @@ Whether or not you set ``case_insensitive``, *please do not* define
1919command method names with any uppercase letters. ``cmd2 `` expects all command methods
2020to be lowercase.
2121
22- Shortcuts
23- =========
22+ Shortcuts (command aliases)
23+ ===========================
2424
25- Special -character shortcuts for common commands can make life more convenient for your
26- users. Shortcuts are used without a space separating them from their arguments,
25+ Command aliases for long command names such as special -character shortcuts for common commands can make life more
26+ convenient for your users. Shortcuts are used without a space separating them from their arguments,
2727like ``!ls ``. By default, the following shortcuts are defined:
2828
2929 ``? ``
@@ -42,7 +42,20 @@ To define more shortcuts, update the dict ``App.shortcuts`` with the
4242{'shortcut': 'command_name'} (omit ``do_ ``)::
4343
4444 class App(Cmd2):
45- Cmd2.shortcuts.update({'*': 'sneeze', '~': 'squirm'})
45+ def __init__(self):
46+ # Make sure you update the shortcuts attribute before calling the super class __init__
47+ self.shortcuts.update({'*': 'sneeze', '~': 'squirm'})
48+
49+ # Make sure to call this super class __init__ after updating shortcuts
50+ cmd2.Cmd.__init__(self)
51+
52+ .. warning ::
53+
54+ Command aliases needed to be created by updating the ``shortcuts `` dictionary attribute prior to calling the
55+ ``cmd2.Cmd `` super class ``__init__() `` method. Moreover, that super class init method needs to be called after
56+ updating the ``shortcuts `` attribute This warning applies in general to many other attributes which are not
57+ settable at runtime such as ``commentGrammars ``, ``multilineCommands ``, etc.
58+
4659
4760Default to shell
4861================
0 commit comments