def call_commands(text)
@task_manager.invoke_and_wait do
get_hooks("pre_command").each {|hook|
break if text == nil
text = hook.call(text)
}
return if text.empty?
commands = find_commands(text)
raise CommandNotFound, text if commands.empty?
commands.each do |command|
command_str, command_arg = Command.split_command_line(text)
modified_arg = command_arg
get_hooks("modify_arg_for_#{command.name.to_s}").each {|hook|
break if modified_arg == false
modified_arg = hook.call(command_str, modified_arg)
}
begin
call_hooks("pre_exec_#{command.name.to_s}", command, modified_arg)
result = command.call(command_str, modified_arg, text)
call_hooks("post_exec_#{command.name.to_s}", command_str, modified_arg, result)
rescue CommandCanceled
end
end
call_hooks("post_command", text)
end
end