Documentation
¶
Overview ¶
Package cli mounts an apisurface.Surface as cobra commands. Every command calls the product's HTTP API exactly as the OpenAPI contract describes it; products supply the base URL and authorization, embed their generated api-surface.json and call Mount from their root command.
Index ¶
Constants ¶
View Source
const ( ExitFailure = 1 // any other failure ExitInvalid = 2 // invalid input or HTTP 400/422 ExitDenied = 4 // HTTP 402/403/429 ExitNotFound = 5 // HTTP 404 ExitConflict = 6 // HTTP 409 ExitConfirmation = 9 // confirmation required or declined )
Exit codes returned through ExitError.
Variables ¶
This section is empty.
Functions ¶
func LoadSurface ¶
LoadSurface decodes an embedded api-surface.json.
Types ¶
type Config ¶
type Config struct {
// BaseURL returns the API origin, e.g. "https://api.kombify.io/v1/techstack".
BaseURL func(ctx context.Context) (string, error)
// ResolvePath optionally maps the contract path (parameters substituted)
// to the path under BaseURL, e.g. to strip a prefix the edge re-adds.
ResolvePath func(path string) string
// HTTPClient defaults to http.DefaultClient.
HTTPClient *http.Client
// Authorize adds credentials to an outgoing request; nil sends none. It
// is never called for --dry-run or refused confirmations.
Authorize func(*http.Request) error
// In, Out and Err default to the process streams.
In io.Reader
Out, Err io.Writer
// Interactive reports whether a human can answer a confirmation prompt;
// nil means non-interactive, so confirmations fail closed.
Interactive func() bool
}
Config binds the generated commands to a product runtime.
Click to show internal directories.
Click to hide internal directories.