def go(&stream_block)
      @status = :running

      begin
        if @content
          @from_file = Tempfile.new('chloride-content')
          @from = @from_file.path
          @from_file.write(@content)
          @from_file.flush
          @from_file.close
        end

        cmd_event = Chloride::Event.new(:action_progress, name, hostname: @to_host)
        msg = Chloride::Event::Message.new(:info, @to_host, "Copying #{@from} to #{@to_host.hostname}:#{@to}.\n\n")
        cmd_event.add_message(msg)
        stream_block.call(cmd_event)

        file_pcts = Hash.new { |h, k| h[k] = 0 }
        @to_host.upload!(@from, @to, @opts) do |_, file, sent, size|
          pct = size.zero? ? 100 : (100.0 * sent / size).to_i
          if [0, 100].include?(pct) || pct > file_pcts[file] + 5
            file_pcts[file] = pct
            evt = Chloride::Event.new(:progress_indicator, name, task: "Copying #{file}", percent: pct)
            stream_block.call(evt)
          end
        end

        @status = :success
      rescue Net::SCP::Error => err
        @status = :fail
        msg = Chloride::Event::Message.new(:error, @to_host, "Could not copy '#{@from}' to #{@to_host.hostname}: #{err}")
        cmd_event.add_message(msg)
        stream_block.call(cmd_event)
      end
    end
def go(&stream_block)
      @status = :running

      begin
        if @content
          @from_file = Tempfile.new('chloride-content')
          @from = @from_file.path
          @from_file.write(@content)
          @from_file.flush
          @from_file.close
        end

        cmd_event = Chloride::Event.new(:action_progress, name, hostname: @to_host)
        msg = Chloride::Event::Message.new(:info, @to_host, "Copying #{@from} to #{@to_host.hostname}:#{@to}.\n\n")
        cmd_event.add_message(msg)
        stream_block.call(cmd_event)

        file_pcts = Hash.new { |h, k| h[k] = 0 }
        @to_host.upload!(@from, @to, @opts) do |_, file, sent, size|
          pct = size.zero? ? 100 : (100.0 * sent / size).to_i
          if [0, 100].include?(pct) || pct > file_pcts[file] + 5
            file_pcts[file] = pct
            evt = Chloride::Event.new(:progress_indicator, name, task: "Copying #{file}", percent: pct)
            stream_block.call(evt)
          end
        end

        @status = :success
      rescue Net::SCP::Error => err
        @status = :fail
        msg = Chloride::Event::Message.new(:error, @to_host, "Could not copy '#{@from}' to #{@to_host.hostname}: #{err}")
        cmd_event.add_message(msg)
        stream_block.call(cmd_event)
      end
    end
TODO: Document args
 TODO: Document block format