Documentation
¶
Overview ¶
Package output is what the commands of both subtrees, `dormeto aws …` and `dormeto gcp …`, print alike: where their words go (stdout, or stderr under --json, whose stdout holds the JSON alone), their JSON, the question asked before a write (--yes skips it and is needed without a terminal) with its decline, and the JSON of a write that stopped before sending anything. It knows no cloud: each subtree passes its flags, its streams and its terminal.
Index ¶
- Constants
- Variables
- func EmptyIfNil[T any](s []T) []T
- func JSON(w io.Writer, v any) error
- func NeedsYes(n int, noun string) error
- func Stop(stdout io.Writer, asJSON bool, key string, value bool, names []string) error
- func Words(asJSON bool, stdout, stderr io.Writer) io.Writer
- type Asker
- type Question
Constants ¶
const NotConfirmed = "not confirmed: nothing sent"
NotConfirmed is the line of a question declined: nothing is sent, exit 0.
Variables ¶
var ErrNeedsYes = errors.New("confirmation needed")
ErrNeedsYes is a question that cannot be asked, stdin not being a terminal: --yes acts without asking. Both subtrees end with exit 2 on it.
Functions ¶
func EmptyIfNil ¶
func EmptyIfNil[T any](s []T) []T
EmptyIfNil is s, or an empty list when nil: JSON's [] rather than null.
func JSON ¶
JSON prints v on w as the commands print their JSON: indented by two spaces, a line feed after it (a raw answer indented too).
func NeedsYes ¶
NeedsYes is ErrNeedsYes for n targets, each a noun: "confirmation needed: pass --yes to act on 2 workloads without a terminal".
Types ¶
type Asker ¶
type Asker struct {
JSON, Yes bool
Stdout, Stderr io.Writer
Terminal func() bool
Confirm func(words io.Writer, question string) (bool, error)
}
Asker asks the questions of a command: its --json and --yes, its streams, whether stdin is a terminal (read only when a question is to be asked) and how a question is asked there (on words, the words' stream; true for a yes).