769
769
class CommandHooks(Hooks):
770
770
"""Hooks related to Command object creation/enumeration."""
772
def __init__(self, module_name, member_name):
773
773
"""Create the default hooks.
775
775
These are all empty initially, because by default nothing should get
779
self.create_hook(HookPoint('extend_command',
778
Hooks.__init__(self, module_name, member_name)
779
self.add_hook('extend_command',
780
780
"Called after creating a command object to allow modifications "
781
781
"such as adding or removing options, docs etc. Called with the "
782
"new bzrlib.commands.Command object.", (1, 13), None))
783
self.create_hook(HookPoint('get_command',
782
"new bzrlib.commands.Command object.", (1, 13))
783
self.add_hook('get_command',
784
784
"Called when creating a single command. Called with "
785
785
"(cmd_or_None, command_name). get_command should either return "
786
786
"the cmd_or_None parameter, or a replacement Command object that "
787
787
"should be used for the command. Note that the Command.hooks "
788
788
"hooks are core infrastructure. Many users will prefer to use "
789
789
"bzrlib.commands.register_command or plugin_cmds.register_lazy.",
791
self.create_hook(HookPoint('get_missing_command',
791
self.add_hook('get_missing_command',
792
792
"Called when creating a single command if no command could be "
793
793
"found. Called with (command_name). get_missing_command should "
794
794
"either return None, or a Command object to be used for the "
795
"command.", (1, 17), None))
796
self.create_hook(HookPoint('list_commands',
796
self.add_hook('list_commands',
797
797
"Called when enumerating commands. Called with a set of "
798
798
"cmd_name strings for all the commands found so far. This set "
799
799
" is safe to mutate - e.g. to remove a command. "
800
800
"list_commands should return the updated set of command names.",
803
Command.hooks = CommandHooks()
803
Command.hooks = CommandHooks("bzrlib.commands", "Command.hooks")
806
806
def parse_args(command, argv, alias_argv=None):