Documentation
¶
Overview ¶
Package action is the write side of the data layer: it turns a declared cfg.Action plus a set of input values into something concrete, and normalises whatever comes back into one Result.
It sits alongside internal/pipeline rather than inside it. Pipelines are the read side — polled, refreshed, cached — and an action is the one thing in the config that must never be re-run just because a timer fired. Keeping them in separate packages is that invariant made structural.
Like the rest of the data layer this package MUST NOT import internal/screen, internal/build, or any tuilib package; the boundary is enforced by scripts/check-data-layer-boundary.sh. That constraint is what splits resolution from execution: Resolve turns inputs into a concrete argv or *http.Request and stops. Running an exec action in a TUI wants tuilib's runner.CaptureWith (so output streams into the console), which lives on the other side of the boundary — so the consumer runs it, we only say what to run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Inputs ¶
Inputs collects the values an action's declared inputs resolve to. Built by the caller from a binding's bind: map, the generated form's values, and each input's Default.
type Resolved ¶
type Resolved struct {
Kind string
// Argv is the concrete command line for an exec action.
Argv []string
// The http fields, post-substitution.
Method string
URL string
Headers map[string]string
Body string
Timeout time.Duration
// contains filtered or unexported fields
}
Resolved is a fully-substituted action, ready to run. Exec actions carry an argv; http actions carry everything needed to build a request. Produced by Resolve, consumed by the TUI (which runs exec through tuilib's capture) or by Do (which runs http here).
func Resolve ¶
Resolve substitutes inputs into an action's templated fields and returns something concrete. Missing values resolve to the input's Default, then to the empty string — the same forgiving behaviour the cursor-fetch path uses, so a URL stays well-formed rather than carrying a literal ${inputs.x} to the far end.
func (*Resolved) Do ¶
Do runs a resolved http action and normalises the response. Exec actions are not run here — see the package doc.
func (*Resolved) Finish ¶
Finish normalises a raw (code, output) pair into a Result, applying the action's success: / message: / error_message: declarations.
Exported because the exec path produces its code and output on the TUI side (tuilib's capture owns the process) and needs the same verdict logic applied to it.
func (*Resolved) Receipt ¶ added in v0.5.0
Receipt is the statusbar line for a successful run, when the action says one: its message: template can't be known before the run, so only a claim's default qualifies. "" leaves the shell's own.
func (*Resolved) Values ¶
Values is the effective input set this action resolved with — bind: values and form entries, with declared Defaults filled in.
Callers preview an action before running it (a confirm message naming what is about to happen) and MUST substitute against this rather than against the raw bind map, or a defaulted input renders empty in the preview while the argv gets the real value. A confirm that disagrees with what runs is worse than no confirm.
type Result ¶
type Result struct {
// OK is the verdict: per-kind default, or the action's `success:`
// expression when it declares one.
OK bool
// Code is the exit status (exec) or HTTP status (http).
Code int
// Output is stdout (exec) or the response body (http).
Output string
// Summary is the head line — what paints the statusbar and heads the
// console entry. Comes from the action's message: / error_message:
// when set, otherwise a per-kind default.
Summary string
}
Result is the normalised outcome of any action kind. The two kinds report success differently — an exit status and an HTTP status aren't the same thing — so the normalisation happens here, once, rather than at every consumer.