     GenServer.call(cmd, {:client})
   end
 
+  # returns the string length from the list_lines
+  defp list_line_length(l) when is_binary(l) do
+    byte_size(l)
+  end
+  defp list_line_length([l | rest]) when is_binary(l) do
+    list_line_length(l) + list_line_length(rest)
+  end
+  defp list_line_length(l) when is_list(l) do # when is char list (as from stdin)
+    Enum.count(l)
+  end
+
   ## server implementation
   def init({cmd, args, cmdopts, perms}) do
     Process.flag(:trap_exit, true)

  end

  def handle_info({ _, {:data, {:eol, line}}}, state) do
    case RPC.Client.parse_line(state.client, line) do
      {:error, e} ->
        Logger.error("Error parsing line: #{inspect e}")
        Logger.debug("Offending line is: #{line}")
      _ -> nil
    end
    {:noreply, state}
  end
  def handle_info({:EXIT, port, :normal}, state) when is_port(port) do
    {:stop, :normal, state}

      cmd: cmd,
      port: port,
      client: client,
      line: [],
    }
    {:ok, state}
  end
