ExQuality.OutputCollector (ExQuality v0.13.0)
View SourceCollects command output without streaming to console.
Implements the Collectable protocol for use with System.cmd/3's :into option. Stores all output in memory for later retrieval.
Example
collector = ExQuality.OutputCollector.new()
{_output, _exit_code} = System.cmd("mix", ["compile"], into: collector)
output = ExQuality.OutputCollector.get_output(collector)Watching output as it arrives
A collector can also be given an :on_line handler, called with each
complete line as the command produces it:
collector = ExQuality.OutputCollector.new(on_line: &IO.puts/1)A stage whose tool can stall for minutes needs this to report progress while it happens; the collected output is only available once the command has exited. Lines are reassembled here because a chunk arrives at whatever boundary the port gives it, which is rarely a line.
Summary
Types
@type t() :: %ExQuality.OutputCollector{pid: pid()}