46
from bzrlib.hooks import Hooks
49
from bzrlib.hooks import HookPoint, Hooks
47
50
# Compatibility - Option used to be in commands.
48
51
from bzrlib.option import Option
49
52
from bzrlib.plugin import disable_plugins, load_plugins
772
775
These are all empty initially, because by default nothing should get
775
Hooks.__init__(self, "bzrlib.commands", "Command.hooks")
776
self.add_hook('extend_command',
779
self.create_hook(HookPoint('extend_command',
777
780
"Called after creating a command object to allow modifications "
778
781
"such as adding or removing options, docs etc. Called with the "
779
"new bzrlib.commands.Command object.", (1, 13))
780
self.add_hook('get_command',
782
"new bzrlib.commands.Command object.", (1, 13), None))
783
self.create_hook(HookPoint('get_command',
781
784
"Called when creating a single command. Called with "
782
785
"(cmd_or_None, command_name). get_command should either return "
783
786
"the cmd_or_None parameter, or a replacement Command object that "
784
787
"should be used for the command. Note that the Command.hooks "
785
788
"hooks are core infrastructure. Many users will prefer to use "
786
789
"bzrlib.commands.register_command or plugin_cmds.register_lazy.",
788
self.add_hook('get_missing_command',
791
self.create_hook(HookPoint('get_missing_command',
789
792
"Called when creating a single command if no command could be "
790
793
"found. Called with (command_name). get_missing_command should "
791
794
"either return None, or a Command object to be used for the "
793
self.add_hook('list_commands',
795
"command.", (1, 17), None))
796
self.create_hook(HookPoint('list_commands',
794
797
"Called when enumerating commands. Called with a set of "
795
798
"cmd_name strings for all the commands found so far. This set "
796
799
" is safe to mutate - e.g. to remove a command. "
797
800
"list_commands should return the updated set of command names.",
800
803
Command.hooks = CommandHooks()