@@ -78,9 +78,9 @@ reasons:
78
78
- The ` cmd.Cmd.__init__() ` method in the python standard library does not call ` super().__init__() ` .
79
79
Because of this oversight, if you don't inherit from ` MyMixin ` first, the ` MyMixin.__init__() `
80
80
method will never be called.
81
- - You may want your mixin to be able to override methods from ` cmd2.Cmd ` . If you mixin the plugin
82
- after ` cmd2.Cmd ` , the python method resolution order will call ` cmd2.Cmd ` methods before it calls
83
- those in your plugin .
81
+ - You may want your mixin to be able to override methods from ` cmd2.Cmd ` . If you mixin the mixin
82
+ class after ` cmd2.Cmd ` , the python method resolution order will call ` cmd2.Cmd ` methods before it
83
+ calls those in your mixin .
84
84
85
85
### Add commands
86
86
@@ -95,7 +95,7 @@ class MyMixin:
95
95
self .poutput(statement)
96
96
```
97
97
98
- You have all the same capabilities within the plugin that you do inside a ` cmd2.Cmd ` app, including
98
+ You have all the same capabilities within the mixin that you do inside a ` cmd2.Cmd ` app, including
99
99
argument parsing via decorators and custom help methods.
100
100
101
101
### Add (or hide) settings
@@ -123,8 +123,8 @@ their own commands.
123
123
124
124
Your mixin can override core ` cmd2.Cmd ` methods, changing their behavior. This approach should be
125
125
used sparingly, because it is very brittle. If a developer chooses to use multiple mixins in their
126
- application, and several of the mixins override the same method, only the first plugin to be mixed
127
- in will have the overridden method called.
126
+ application, and several of the mixins override the same method, only the first mixin to be mixed in
127
+ will have the overridden method called.
128
128
129
129
Hooks are a much better approach.
130
130
@@ -148,7 +148,7 @@ class MyMixin:
148
148
super ().__init__ (* args, ** kwargs)
149
149
# code placed here runs after cmd2 initializes
150
150
# this is where you register any hook functions
151
- self .register_postparsing_hook(self .cmd2_myplugin_postparsing_hook )
151
+ self .register_postparsing_hook(self .cmd2_mymixin_postparsing_hook )
152
152
153
153
def cmd2_mymixin_postparsing_hook (self , data : cmd2.plugin.PostparsingData) -> cmd2.plugin.PostparsingData:
154
154
""" Method to be called after parsing user input, but before running the command"""
0 commit comments