How to capture each line from System.cmd output?
<p>How to capture each line written in console when run commands from <code>System.cmd</code> or by other approach?</p>

<p>I want even capture final results but what is displayed in console in this case it will be similar to: <code>Cloning into 'myrepo'... remote: Counting objects: 3271, done.</code> and send each line via channels:</p>

<pre><code>case System.cmd("git", ["clone", "git@github.com:#{vault}/#{repo}.git"], cd: repo) do
  {results, 0} -&gt;
    Myapp.Endpoint.broadcast("app:setup", "new:line", results)
  {_, code} -&gt;
    raise RuntimeError, "`git clone` failed with code #{code}"
end
</code></pre>

<p>I haven't found solution, there was similar issues but without clear answer: <a href="https://stackoverflow.com/questions/34165458/execute-command-and-stream-results">question</a> or <a href="https://stackoverflow.com/questions/25342212/how-to-start-an-os-process-in-elixir">question</a></p>