Juggernaut.CLI.RunOutput (Juggernaut v0.4.0)

Copy Markdown View Source

What mix juggernaut writes while a run goes and when it ends (design notes §5): a pure reducer over the engine's run events (Juggernaut.View.Stream.event/0).

  • --stream: every event becomes its NDJSON lines on stdout (Juggernaut.View.Stream); with --format agent the last line holds the agent document (event report). Nothing else goes to stdout.
  • human: the live view (Juggernaut.View.Live): progress on stderr, each survivor as it is found and the summary on stdout.
  • agent, json, markdown, github: the live view's stderr lines only; the format's document is written once, at the end (document/2), so stdout holds that document alone.

handle/3 returns the writes, in order, as {:stdout | :stderr, iodata}.

Summary

Functions

The whole document of run in the output's format (for --output PATH).

What to write to stdout once the run has finished: nothing for human and for --stream (both already wrote it), else the format's document.

Takes one event at t_ms (milliseconds since the run started).

An output for format. Options: stream (NDJSON, default false), tty (redraw the progress line; never with stream) and the view options of Juggernaut.View.

Replaces view options (for example the sources, once the plan names the files).

Types

format()

@type format() :: :human | :agent | :json | :markdown | :github

t()

@type t() :: %Juggernaut.CLI.RunOutput{
  format: format(),
  live: Juggernaut.View.Live.t(),
  opts: Juggernaut.View.options(),
  run_id: String.t() | nil,
  stream?: boolean()
}

write()

@type write() :: {:stdout | :stderr, iodata()}

Functions

document(output, run)

@spec document(t(), Juggernaut.Run.t()) :: iodata()

The whole document of run in the output's format (for --output PATH).

final(output, run)

@spec final(t(), Juggernaut.Run.t()) :: iodata()

What to write to stdout once the run has finished: nothing for human and for --stream (both already wrote it), else the format's document.

handle(output, event, t_ms)

@spec handle(t(), Juggernaut.View.Stream.event(), non_neg_integer()) ::
  {[write()], t()}

Takes one event at t_ms (milliseconds since the run started).

new(format, opts \\ [])

@spec new(format(), keyword()) :: t()

An output for format. Options: stream (NDJSON, default false), tty (redraw the progress line; never with stream) and the view options of Juggernaut.View.

put_options(output, opts)

@spec put_options(t(), keyword()) :: t()

Replaces view options (for example the sources, once the plan names the files).