@@ -19,11 +19,11 @@ Whether or not you set ``case_insensitive``, *please do not* define
19
19
command method names with any uppercase letters. ``cmd2 `` expects all command methods
20
20
to be lowercase.
21
21
22
- Shortcuts
23
- =========
22
+ Shortcuts (command aliases)
23
+ ===========================
24
24
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,
27
27
like ``!ls ``. By default, the following shortcuts are defined:
28
28
29
29
``? ``
@@ -42,7 +42,20 @@ To define more shortcuts, update the dict ``App.shortcuts`` with the
42
42
{'shortcut': 'command_name'} (omit ``do_ ``)::
43
43
44
44
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
+
46
59
47
60
Default to shell
48
61
================
0 commit comments