Property for child classes to access self._cmd_internal. Using this property ensures that the CommandSet has been registered and tells type checkers that self._cmd_internal is not None. Subclasses can specify their specific Cmd type during inheritance: class My
(self)
| 43 | |
| 44 | @property |
| 45 | def _cmd(self) -> CmdT: |
| 46 | """Property for child classes to access self._cmd_internal. |
| 47 | |
| 48 | Using this property ensures that the CommandSet has been registered |
| 49 | and tells type checkers that self._cmd_internal is not None. |
| 50 | |
| 51 | Subclasses can specify their specific Cmd type during inheritance: |
| 52 | |
| 53 | class MyCommandSet(CommandSet[MyCustomApp]): |
| 54 | ... |
| 55 | |
| 56 | :raises CommandSetRegistrationError: if CommandSet is not registered. |
| 57 | """ |
| 58 | if self._cmd_internal is None: |
| 59 | raise CommandSetRegistrationError("This CommandSet is not registered") |
| 60 | return self._cmd_internal |
| 61 | |
| 62 | def on_register(self, cmd: CmdT) -> None: |
| 63 | """First step to registering a CommandSet, called by cmd2.Cmd. |
nothing calls this directly
no test coverage detected