output

package
v0.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const NotConfirmed = "not confirmed: nothing sent"

NotConfirmed is the line of a question declined: nothing is sent, exit 0.

Variables

View Source
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

func JSON(w io.Writer, v any) error

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

func NeedsYes(n int, noun string) error

NeedsYes is ErrNeedsYes for n targets, each a noun: "confirmation needed: pass --yes to act on 2 workloads without a terminal".

func Stop

func Stop(stdout io.Writer, asJSON bool, key string, value bool, names []string) error

Stop prints on stdout, under --json, why nothing was sent and to what: {<key>: <value>, "targets": [names]}, [] for none ({"confirmed": false, …} for a question declined, {"dryRun": true, …} for a dry run).

func Words

func Words(asJSON bool, stdout, stderr io.Writer) io.Writer

Words is where a command says what it does and asks its questions: stdout, or stderr under its --json, whose stdout holds the JSON alone.

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).

func (Asker) Ask

func (a Asker) Ask(q Question) (done bool, err error)

Ask asks q on the terminal: --yes skips it, and it is refused without a terminal (NeedsYes). done is true when it is declined: NotConfirmed said on the words' stream and, under --json, {"confirmed": false, "targets": [names]} printed on stdout; nothing is sent.

type Question

type Question struct {
	Names          []string
	Noun, Text     string
	Always, Listed bool
}

Question is asked before a write acts on Names, each a Noun ("router", "workload"): Text as it is written (it names the targets and what happens), for several names, or for one too when Always; the names listed first, each on its line, indented, when Listed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL