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

Method on_register

cmd2/command_set.py:62–74  ·  view source on GitHub ↗

First step to registering a CommandSet, called by cmd2.Cmd. The commands defined in this class have not been added to the CLI object at this point. Subclasses can override this to perform any initialization requiring access to the Cmd object (e.g. configure commands and thei

(self, cmd: CmdT)

Source from the content-addressed store, hash-verified

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.
64
65 The commands defined in this class have not been added to the CLI object at this point.
66 Subclasses can override this to perform any initialization requiring access to the Cmd object
67 (e.g. configure commands and their parsers based on CLI state data).
68
69 :param cmd: The cmd2 main application
70 :raises CommandSetRegistrationError: if CommandSet is already registered.
71 """
72 if self._cmd_internal is not None:
73 raise CommandSetRegistrationError("This CommandSet has already been registered")
74 self._cmd_internal = cmd
75
76 def on_registered(self) -> None:
77 """2nd step to registering, called by cmd2.Cmd after a CommandSet is registered and all its commands have been added.

Callers 1

register_command_setMethod · 0.45

Calls 1

Tested by

no test coverage detected