MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / _cmd

Method _cmd

cmd2/command_set.py:45–60  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected