Documentation
¶
Overview ¶
Package batch collects multi-input arguments (positional args, stdin, or --from-file) and renders per-input results as a stable JSON envelope.
The envelope shape is the contract: agents that piped 50 PURLs into the CLI can rely on receiving a 50-element array with matching .input keys and per-row .data or .error. Never break this shape.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoInputs = errors.New("no inputs provided")
ErrNoInputs is returned by CollectInputs callers when they need to surface "you provided nothing" as a validation error.
Functions ¶
func CollectInputs ¶
CollectInputs resolves the set of inputs to operate on.
args - positional CLI arguments (caller passes cobra's args slice) fromFile - value of --from-file (empty = unset) stdin - reader to use for stdin fallback; nil defaults to os.Stdin
Precedence: --from-file wins, then positional args, then stdin if it is not a terminal. Empty/whitespace lines and leading '#' comment lines are skipped. Returns an empty slice if no source provided any input.
Types ¶
type Result ¶
type Result struct {
Input string `json:"input"`
Data any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
Result is one row of the batch output envelope.
func ResultFromData ¶
ResultFromData builds a success Result.
func ResultFromError ¶
ResultFromError builds a failure Result. If the error is nil this is equivalent to ResultFromData with data=nil — usually you'd call ResultFromData directly in that case.