Documentation
¶
Overview ¶
Package output renders responses and diagnostics, and owns the exit-code contract.
Index ¶
- Constants
- func Authf(format string, args ...any) error
- func Blockedf(format string, args ...any) error
- func Configf(format string, args ...any) error
- func ExitCodeFor(err error) int
- func ExitCodeForStatus(status int) int
- func Silent(code int) error
- func Usagef(format string, args ...any) error
- func ValidateMode(mode string) error
- func WithCode(err error, code int) error
- type Redactor
- type Renderer
Constants ¶
const ( ExitOK = 0 // 2xx ExitInternal = 1 // unexpected internal error ExitUsage = 2 // bad flags, missing required param, unknown operation ExitConfig = 3 // no config file, bad env, malformed TOML ExitAuth = 4 // 401/403, or credential resolution failed ExitBlocked = 5 // blocked by a safety rule ExitTransport = 6 // DNS, connection refused, timeout, TLS ExitClient = 7 // 4xx other than 401/403 ExitServer = 8 // 5xx ExitSchema = 9 // response did not match the spec schema, under --strict )
The exit-code contract. A caller branches on these, so they never change meaning.
const ( ModeJSON = "json" ModeRaw = "raw" ModeStatus = "status" )
Output modes.
const Placeholder = "<redacted>"
Placeholder is what replaces a secret in any output blip produces.
Variables ¶
This section is empty.
Functions ¶
func ExitCodeFor ¶
ExitCodeFor reports the exit code for err. An untagged error is a bug in blip, not a predictable failure, so it maps to ExitInternal.
func ExitCodeForStatus ¶
ExitCodeForStatus maps an HTTP status onto blip's exit-code contract. Anything that is not 2xx, 401, 403 or 5xx is reported as a client error, including a 3xx that survived redirect handling.
func Silent ¶
Silent carries an exit code with nothing left to say, for when the failure has already been reported in full: a 404 body is the message, and "blip: error" on top of it is noise.
func Usagef ¶
Constructors for the coded errors, so that every package tags failures the same way and the contract stays readable from this one file.
func ValidateMode ¶
ValidateMode rejects an unknown --output value.
Types ¶
type Redactor ¶
type Redactor struct {
// contains filtered or unexported fields
}
Redactor keeps secrets out of verbose and dry-run output.
func NewRedactor ¶
NewRedactor redacts the always-secret headers, any extra header the profile names, and the literal secret values themselves wherever they appear.
func (*Redactor) HeaderValue ¶
HeaderValue redacts a header value, keeping the auth scheme visible because knowing it is Bearer rather than Basic is diagnostic, not secret.
type Renderer ¶
type Renderer struct {
Mode string
Pretty bool
IncludeHeaders bool
Stdout io.Writer
Stderr io.Writer
Redactor *Redactor
}
Renderer writes a response according to the output contract: body on stdout, everything else on stderr.
func (*Renderer) DryRun ¶
DryRun renders a request without sending it. The format is a contract an agent reads, so it stays stable: request line, environment, headers, blank line, body.