WardrikDaemon.CLI.Terminal (wardrik_daemon v0.1.0-rc.1)

Copy Markdown

The terminal a command writes to: how wide it is, whether it takes colour, and whether someone types at it.

It takes colour if standard output is a terminal, NO_COLOR isn't set and TERM isn't dumb. Otherwise, as through a pipe, it writes plain text 80 columns wide. Someone types at it where WARDRIK_INPUT is 1, as bin/wardrik sets it where standard input is a terminal.

Summary

Functions

Writes each of lines.

Returns the terminal standard output is, with env, the environment, saying whether it takes colour and input.

Writes data and a newline, styled if the terminal takes colour.

Asks for a line with prompt, not showing what's typed where it can. Returns nil for none.

Types

t()

@type t() :: %WardrikDaemon.CLI.Terminal{
  colour?: boolean(),
  input?: boolean(),
  width: pos_integer()
}

Functions

lines(terminal, lines)

@spec lines(t(), [Owl.Data.t()]) :: :ok

Writes each of lines.

new(env)

@spec new(%{required(String.t()) => String.t()}) :: t()

Returns the terminal standard output is, with env, the environment, saying whether it takes colour and input.

puts(terminal, data)

@spec puts(t(), Owl.Data.t()) :: :ok

Writes data and a newline, styled if the terminal takes colour.

secret(terminal, prompt)

@spec secret(t(), String.t()) :: String.t() | nil

Asks for a line with prompt, not showing what's typed where it can. Returns nil for none.