# File lib/termtter/client.rb, line 154
      def execute(text)
        text = text.strip

        @task_manager.invoke_and_wait do
          # FIXME: This block can become Maybe Monad
          get_hooks("pre_command").each {|hook|
            break if text == nil # interrupt if hook returns 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 ||= ''

          # FIXME: This block can become Maybe Monad
          get_hooks("modify_arg_for_#{command.name.to_s}").each {|hook|
            break if modified_arg == false # interrupt if hook return 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) # exec command
            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