# `Juggernaut.View.Live`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/view/live.ex#L1)

The human view of a run as it goes (design notes §5.1): a quiet progress line, each
survivor printed as soon as it is found, then the summary.

A pure reducer over the run's events (`t:Juggernaut.View.Stream.event/0`): `handle/3`
takes the state, one event and the milliseconds since the run started, and returns what
to write and the new state. The caller writes each `{:stdout, iodata}` and
`{:stderr, iodata}` in order.

On a terminal (`tty: true`) the progress line (phase, mutants done of the planned total,
killed, survived, no coverage when any, workers, elapsed; counted as the summary counts
them, so a timeout kill is killed even when listed with the survivors) is redrawn in place on stderr and cleared before
anything else is written. Otherwise there are no redraws and no control sequences: one
stderr line per phase, plan, worker recycle and warning. Survivors and the summary go to
stdout either way.

Options: `tty` (default `false`) and those of `Juggernaut.View`.

# `output`

```elixir
@type output() :: [{:stdout | :stderr, iodata()}]
```

# `t`

```elixir
@type t() :: %Juggernaut.View.Live{
  done: non_neg_integer(),
  finished?: boolean(),
  killed: non_neg_integer(),
  no_coverage: non_neg_integer(),
  opts: Juggernaut.View.options(),
  phase: atom() | nil,
  survived: non_neg_integer(),
  t_ms: non_neg_integer(),
  total: non_neg_integer() | nil,
  tty?: boolean(),
  workers: pos_integer() | nil
}
```

# `handle`

```elixir
@spec handle(t(), Juggernaut.View.Stream.event(), non_neg_integer()) ::
  {output(), t()}
```

Takes one event at `t_ms`; returns what to write, in order, and the new state.

# `new`

```elixir
@spec new(keyword()) :: t()
```

A live view. `tty: true` redraws a progress line on stderr.

# `progress`

```elixir
@spec progress(t()) :: String.t()
```

The progress line of the current state, without control sequences.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
