def execute(text)
text = text.strip
@task_manager.invoke_and_wait do
get_hooks("pre_command").each {|hook|
break if text == nil
text = hook.call(text)
}
return if text.empty?
command = find_command(text)
raise CommandNotFound, text unless command
command_str, modified_arg = command.split_command_line(text)
command_str.strip!
modified_arg ||= ''
get_hooks("modify_arg_for_#{command.name.to_s}").each {|hook|
break if modified_arg == false
modified_arg.strip!
modified_arg = hook.call(command_str, modified_arg) || ''
}
modified_arg.strip!
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)
call_hooks("post_command", text)
rescue CommandCanceled
return false
end
return true
end
rescue TimeoutError
call_hooks("timeout", text)
raise
end