677
677
if line.startswith(':') and line.endswith(':') and len(line) > 2:
678
678
save_section(sections, order, label, section)
679
679
label, section = line[1:-1], ''
680
elif (label is not None) and len(line) > 1 and not line[0].isspace():
680
elif (label is not None and len(line) > 1 and
681
not line[0].isspace()):
681
682
save_section(sections, order, label, section)
682
683
label, section = None, line
853
854
Hooks.__init__(self, "breezy.commands", "Command.hooks")
854
self.add_hook('extend_command',
855
"Called after creating a command object to allow modifications "
856
"such as adding or removing options, docs etc. Called with the "
857
"new breezy.commands.Command object.", (1, 13))
858
self.add_hook('get_command',
859
"Called when creating a single command. Called with "
860
"(cmd_or_None, command_name). get_command should either return "
861
"the cmd_or_None parameter, or a replacement Command object that "
862
"should be used for the command. Note that the Command.hooks "
863
"hooks are core infrastructure. Many users will prefer to use "
864
"breezy.commands.register_command or plugin_cmds.register_lazy.",
866
self.add_hook('get_missing_command',
867
"Called when creating a single command if no command could be "
868
"found. Called with (command_name). get_missing_command should "
869
"either return None, or a Command object to be used for the "
871
self.add_hook('list_commands',
872
"Called when enumerating commands. Called with a set of "
873
"cmd_name strings for all the commands found so far. This set "
874
" is safe to mutate - e.g. to remove a command. "
875
"list_commands should return the updated set of command names.",
877
self.add_hook('pre_command',
878
"Called prior to executing a command. Called with the command "
880
self.add_hook('post_command',
881
"Called after executing a command. Called with the command "
857
"Called after creating a command object to allow modifications "
858
"such as adding or removing options, docs etc. Called with the "
859
"new breezy.commands.Command object.", (1, 13))
862
"Called when creating a single command. Called with "
863
"(cmd_or_None, command_name). get_command should either return "
864
"the cmd_or_None parameter, or a replacement Command object that "
865
"should be used for the command. Note that the Command.hooks "
866
"hooks are core infrastructure. Many users will prefer to use "
867
"breezy.commands.register_command or plugin_cmds.register_lazy.",
870
'get_missing_command',
871
"Called when creating a single command if no command could be "
872
"found. Called with (command_name). get_missing_command should "
873
"either return None, or a Command object to be used for the "
877
"Called when enumerating commands. Called with a set of "
878
"cmd_name strings for all the commands found so far. This set "
879
" is safe to mutate - e.g. to remove a command. "
880
"list_commands should return the updated set of command names.",
884
"Called prior to executing a command. Called with the command "
888
"Called after executing a command. Called with the command "
885
892
Command.hooks = CommandHooks()