Documentation
¶
Index ¶
- Constants
- Variables
- func Answer(yes bool) *bool
- func Cut(line string, width int) string
- func ExitCode(err error) int
- func Exitf(code int, format string, args ...any) error
- func UntilStopped(parent context.Context) (context.Context, context.CancelFunc)
- func Visible(text string) string
- func Wrapped(line string, width int) string
- func WriteError(w io.Writer, err error)
- type Decision
- type Display
- type ExitError
- type Gatherer
- type Stage
- type StatusLine
- type Streams
- func (s Streams) AsTerminal() Streams
- func (s Streams) Ask(question string) (string, error)
- func (s Streams) AskYes(question string, empty bool) (bool, error)
- func (s Streams) Beneath() (io.Reader, io.Writer)
- func (s Streams) Command() string
- func (s Streams) Decide(yes bool, d Decision) (bool, model.Answered, error)
- func (s Streams) Emit(result any)
- func (s Streams) ErrTerminal() bool
- func (s Streams) Finish(args []string, requests int64, err error) error
- func (s Streams) Hanging(first, text string) string
- func (s Streams) Height() int
- func (s Streams) Held() bool
- func (s Streams) JSON() bool
- func (s Streams) LinkSteps(whole Gatherer)
- func (s Streams) OutTerminal() bool
- func (s Streams) Plain() Streams
- func (s Streams) Prose() io.Writer
- func (s Streams) ReadLine() (string, error)
- func (s Streams) Reports(command string, asJSON bool)
- func (s Streams) Say(line string)
- func (s Streams) SetVerbosity(count int)
- func (s Streams) Staged(under string) (Streams, *Stage)
- func (s Streams) Stamped(stamp func(io.Writer) io.Writer) Streams
- func (s Streams) Status() *StatusLine
- func (s Streams) Terminal() bool
- func (s Streams) Unattended() Streams
- func (s Streams) Verbose() int
- func (s Streams) Width() int
- func (s Streams) WithDisplay(display Display) Streams
- func (s Streams) WithProseTap(tap io.Writer) Streams
Constants ¶
const ( // ExitFailure is an error, a refusal among them. ExitFailure = 1 // ExitAttention is an outcome that needs a person's look: a hold, a // look left incomplete, or archives that don't match. ExitAttention = 3 )
The exit codes a command's outcome calls for (Design v3 §12), named so no site chooses a bare number and none reads one back as control flow.
const JSONVersion = 1
JSONVersion is the version of the --json envelope and the results in it.
Variables ¶
StopSignals are the signals that stop a command, each cancelling its context so it unwinds: an interrupt, a terminate, and a hangup, which a closed terminal window or a dropped SSH session sends. Under Go's default a hangup ended the process on the spot, leaving a Tart check's VM running and its clone on disk (#240).
var TableLine = regexp.MustCompile(`\S {2,}\S`)
TableLine is a line whose cells are set apart by two spaces or more, which is set in columns rather than wrapped.
Functions ¶
func Cut ¶
Cut is a table's line cut at width, its end said with "…", as a terminal shows a table's widest free-text cell, the last; -v shows it whole, and off a terminal nothing is cut, since field testing reads dockhand through a pipe and acts on its words. A line that isn't a table's, or fits, is as it is.
func ExitCode ¶
ExitCode is the process exit code for err: its own when it carries one, however wrapped, else its refusal's kind's (refusal.Kind.Exit, the one table of them), else ExitFailure.
func UntilStopped ¶ added in v0.9.0
UntilStopped is parent until one of StopSignals arrives, as signal.NotifyContext makes it, and the function to call once the command is done. A stop signal the process started with ignored stays ignored: nohup starts dockhand with hangups ignored so that it outlives its terminal, and a non-interactive shell starts a background job with interrupts ignored, where asking to be told of one would heed it. Once stopped, writes to standard output or error no longer end the process: the terminal or pipe they went to may be gone with the hangup, and the unwind is worth more than its words, so a write there fails as any write does, with its error, which teardown doesn't wait on, where Go's default for a broken pipe on those two is to end the process as SIGPIPE does. Until then a pipe closed by its reader, as by head, still ends dockhand quietly.
func Visible ¶ added in v0.9.0
Visible is text that is someone else's, a pull request's diff, paths, title or commit subject, made safe to write to a terminal: every control character but newline and tab is shown in a visible form, so that a carriage return, an escape sequence or a backspace in it can't draw over what it is shown beside (#330). A C0 control and DEL show as their Unicode control pictures (␍, ␛, ␡), a C1 control as <U+0085>, and a byte that isn't UTF-8 as <0x9B>, since a terminal not reading UTF-8 takes some of those for C1 controls. The bidirectional formatting characters show as a C1 control does, <U+202E>: an override can show a Portfile line in another order than Tcl reads it. Text with none of these comes back as it was.
func Wrapped ¶
Wrapped is one line as the output's writer sets it at width: broken at its spaces where it's wider and has somewhere to break, its later lines two past its own indent; a table's line, or one with escape codes or a tab, as it is.
func WriteError ¶ added in v0.9.0
WriteError writes a command's final error, as the process ends on it, made safe to show (Visible): it may carry another's words, Git's, GitHub's, or a remote's, which mustn't draw over the terminal (#330, #365). An error with no words writes nothing.
Types ¶
type Decision ¶
type Decision struct {
Question string
Yes bool
Undone string
ByYes string
// Nobody is the answer where nobody is there to ask and none refuses,
// as for a question with a safe way on, stopping a running check
// that a script asked to replace; nil refuses.
Nobody *bool
}
Decision is a yes-or-no question a command asks before it acts: what it asks on a terminal, its answer when the person just presses return, and what was left undone without one, "nothing was removed", with what --yes would do, "--yes removes these".
type Display ¶
type Display struct {
// NoColour is NO_COLOR set, or dockhand console's --plain.
NoColour bool
// Columns is COLUMNS, where it's set; prose off a terminal wraps at it,
// else at 100, since field testing reads dockhand through a pipe.
Columns int
}
Display is how a command line's text is shown, as its environment asks: whether the marks are coloured, and the columns text wraps at where output isn't a terminal. The command line reads them from the environment (NO_COLOR, COLUMNS), as nothing below it does.
type Gatherer ¶
A Gatherer is a command's result that the steps it goes on to report into, so that the command has one shape wherever it stops: what a step didn't reach is left out.
type Stage ¶
type Stage struct {
// contains filtered or unexported fields
}
Stage is a stage's report held back (Staged).
func (*Stage) Done ¶
Done says a stage that went through in its one line, where its report was held back, which is -v's: the report is dropped, unless a question already said it.
type StatusLine ¶
type StatusLine struct {
// contains filtered or unexported fields
}
StatusLine is standard error with at most one line redrawn in place, as outdated redraws its count. A line printed while it shows clears it first and draws it again after, so the two never share a line.
func (*StatusLine) Say ¶
func (s *StatusLine) Say(line string)
Say prints a line of its own, above the line shown.
func (*StatusLine) Show ¶
func (s *StatusLine) Show(text string)
Show draws text in place of what the line showed, cut short of the terminal's width with "…": a line that wrapped left its first row behind at each redraw, since the clear reaches only the cursor's row, and a check's progress read as one long line of every step (#332's try).
type Streams ¶
type Streams struct {
In io.Reader
Out io.Writer
Err io.Writer
// contains filtered or unexported fields
}
Streams are the standard streams a command reads and writes. Out is standard output raw, beneath it only --json's switch, for what comes from a file, a tool or a template: a Portfile, a diff, a log, a completion script, a usage page, a Markdown body. Dockhand's own sentences, tables and views write to Prose, which wraps at the width and colours the marks. The name typed by habit is the safe one: a payload written to Out by mistake for Prose costs a long line, where a wrapped Portfile was a broken one (#94, docs/designs/prose-stream.md at 36675f0d).
func Begin ¶
Begin are the streams a command line runs with: its input read by line, its output switched off while --json gathers the envelope, which args ask for, its output mode, and its status line.
func (Streams) AsTerminal ¶
AsTerminal are the streams as a terminal's, where a test stands one in: every stream is one, and questions are asked of In.
func (Streams) Ask ¶
Ask puts a question on standard error and reads one line. Input that ends without an answer is an empty answer, which takes the default.
func (Streams) AskYes ¶
AskYes asks a yes-or-no question on the terminal, with the answer an empty line gives: Decide's asking half, for a question whose command has made sure a person is there, as setup's offers and submit's tested checkboxes do.
func (Streams) Beneath ¶ added in v0.8.0
Beneath are the input and the output as a view drawn on the whole screen reads and writes them (term/screen): the output beneath the writers Begin puts before it, which would wrap a frame's lines, colour its marks, and break its one write into several.
func (Streams) Command ¶
Command is the command the line runs (Reports), or empty before it's known.
func (Streams) Decide ¶
Decide settles a decision: --yes takes it, a terminal asks it, and otherwise it's refused in one sentence, "nothing was removed: without a terminal, --yes removes these", exit 1. Seven commands each wrote the refusal their own way, two of them exiting 0 (clean's and review --pr's). It says how it was answered; a person's no is an answer, not an error.
func (Streams) ErrTerminal ¶
ErrTerminal reports whether errors and progress go to a terminal, where a line can be redrawn.
func (Streams) Finish ¶
Finish ends a command line of args: where it reports as JSON, its envelope, which carries err and the GitHub requests it sent, is written, and an error is returned that carries only err's exit code; otherwise err as it is. Begin's streams.
func (Streams) Hanging ¶
Hanging is text wrapped at the output's width (Width), its first line after first and the rest after a hanging indent as wide as first, as status's attention list wraps its rows (2026-10-20): one writer for prose, where only that list wrapped, and lines ran to 400 columns. A line is never cut; a word wider than the width overruns it.
func (Streams) Height ¶
Height is the output terminal's rows, for a view to fit; 0 off a terminal, where nothing is fitted.
func (Streams) Held ¶
Held reports whether the streams are a stage's whose report is held back (Staged): its progress, record IDs and provider steps, is -v's then, and on a terminal the line redrawn says the latest.
func (Streams) LinkSteps ¶
LinkSteps makes whole the command's one result, with each later step's inside it, so a script reads one shape wherever the command stopped: ship's and bump's are the batch's, each change's update with its later steps inside, and check's the check's. A command already gathering keeps its own, as ship keeps its batch through each change's submission.
func (Streams) OutTerminal ¶
OutTerminal reports whether the output is a terminal that can be redrawn.
func (Streams) Plain ¶
Plain are the streams with their marks uncoloured, for dockhand console's --plain: line output a script or a log reads.
func (Streams) Prose ¶ added in v0.9.0
Prose is the writer for dockhand's own sentences, tables and views: it wraps at the width, a terminal's or COLUMNS (wrapWriter), and colours the marks on a terminal. Streams never begun, as a test's, write prose to Out as it is.
func (Streams) Reports ¶
Reports names the command the line runs, as its envelope says, and whether it reports as JSON, which silences standard output until Finish writes the envelope. Begin's streams.
func (Streams) SetVerbosity ¶
SetVerbosity records -v's count for the command line, which its streams' every copy reads (Verbose).
func (Streams) Staged ¶
Staged are streams for one stage of a command that runs several, as ship's edit, commit, check, and submission: at the default level, what the stage writes to standard output is held back, and said only where the stage held or failed (Stage.Say) or asks a question, which the person answers from it; with -v it's said as it's written (part 5, item 3: a clean bump printed four stages' full reports, 46 lines, where the person needs a line a stage). On a terminal, the stage under way is the line redrawn on standard error, until it's done or said.
func (Streams) Stamped ¶ added in v0.9.0
Stamped are the streams with each line of standard output, prose and raw alike, passed through stamp first, beneath --json's switch: serve's time stamp off a terminal, which "serve: stopped" lost where Prose was built before it.
func (Streams) Status ¶
func (s Streams) Status() *StatusLine
Status is the command's redrawn line on standard error.
func (Streams) Terminal ¶
Terminal reports whether the input is an interactive terminal, the only place a command may ask a question.
func (Streams) Unattended ¶
Unattended are the streams of a command that asks nothing, whatever its input, as bump does: everything that would ask goes the way it goes without a terminal.
func (Streams) Verbose ¶
Verbose is -v's count: 0 at the default level, 1 with -v, 2 with -vv (Design v3 §12).
func (Streams) Width ¶
Width is the output terminal's columns, for text to wrap at; off a terminal, COLUMNS where it's set (Display), else 100.
func (Streams) WithDisplay ¶
WithDisplay are the streams with how their text is shown. On a terminal, and unless NoColour, the marks standard output prints are coloured (the person's "Marks only", 2026-10-22): ✗ red, ! yellow, ✓ green, and nothing else, no meaning resting on colour alone. Begin wraps the output.
func (Streams) WithProseTap ¶ added in v0.9.0
WithProseTap are the streams with what Prose writes read by tap as well, as it goes to Out, wrapped and coloured, and nothing Out is given raw: a test's reading of dockhand's own words, which a payload, as wide as it came, isn't held to (#94).
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package screen is the terminal a view draws on whole, as dockhand console does: the alternate screen, its input read in raw mode as keys, and a frame drawn in one write at the terminal's size.
|
Package screen is the terminal a view draws on whole, as dockhand console does: the alternate screen, its input read in raw mode as keys, and a frame drawn in one write at the terminal's size. |