Documentation
¶
Overview ¶
Package core holds the CLI's own identity and its exit and error contract. It depends on nothing but the standard library.
Index ¶
Constants ¶
const BootstrapID = "gtt-bootstrap"
BootstrapID is the only Bootstrap identity this CLI operates.
const BootstrapPin = "1.31.4"
BootstrapPin is the exact GTT Bootstrap release this CLI release ships with. Pinning the CLI therefore pins the Bootstrap. It is resolved from its release tag (BootstrapTag), never from a branch head; another release is used only when the human names it explicitly.
const OutputSchema = 1
OutputSchema is the version of every JSON document the CLI emits.
const StaleAfterDays = 21
StaleAfterDays is how old a CLI build may be before it says so. GTT releases often; a CLI that is weeks old runs a Bootstrap that lacks what the newer ones carry.
Variables ¶
var BootstrapSchemas = []int{1}
BootstrapSchemas are the Bootstrap schema versions this CLI understands.
var BuildDate = ""
BuildDate is the day this binary was built (YYYY-MM-DD). Release builds set it with -ldflags; a plain source build leaves it empty and falls back to the VCS time Go recorded, if any.
var CLICapabilities = []string{"contract.negotiate.v1", "operation.execute.v1", "delivery.v1"}
CLICapabilities are the capability ids this CLI declares to a Bootstrap during negotiation.
var ErrCancelled = &Error{Code: ExitCancelled, What: "Cancelled."}
ErrCancelled is returned when the human declines.
var SupportedCapabilities = map[string]int{
"project.detect": 1,
"ade.detect": 1,
"ade.install": 1,
"template.materialize": 1,
"methodology.profile": 1,
"source.select": 1,
"validation": 1,
"status": 1,
"freeze": 1,
"session-context": 1,
"export-policy": 1,
"recovery": 1,
"guard": 1,
"retrieval": 1,
"developer-experience": 1,
"inbox.v1": 1,
}
SupportedCapabilities maps each Bootstrap capability this CLI consumes to the version it implements. A Bootstrap that offers one of these at another version is refused; a capability not listed here is simply not used.
var Version = baseVersion
Version is the CLI release. Each release pins one Bootstrap release (BootstrapPin) with the same number: GTT is released as a suite (ADR-005), and compatibility is still negotiated, never assumed. Release builds set it with -ldflags; `go install module@vX.Y.Z` takes it from the module version; a plain source build keeps this base value.
Functions ¶
func BootstrapTag ¶ added in v1.1.0
BootstrapTag is the release tag of a Bootstrap version.
func ParseSemver ¶
ParseSemver parses MAJOR.MINOR.PATCH; ok is false for anything else.
Types ¶
type Error ¶
type Error struct {
Code ExitCode
What string
Why string
Next string
Unmodified bool // true when the project is known to be untouched
Err error
}
Error is a user-facing error: what happened, why, and what to do next.
type ExitCode ¶
type ExitCode int
ExitCode is the v1.0 exit contract.
const ( ExitOK ExitCode = 0 ExitFailure ExitCode = 1 // validation / operational failure ExitIncompatible ExitCode = 2 // CLI/Bootstrap incompatibility ExitUsage ExitCode = 3 // invalid invocation ExitCancelled ExitCode = 4 // user cancellation ExitConflict ExitCode = 5 // project state conflict ExitIntegrity ExitCode = 6 // Bootstrap integrity failure )
type LangSource ¶ added in v1.8.0
type LangSource int
LangSource ranks where a language choice came from: a lower one wins.
const ( // LangExplicit is --language, or the human's answer in init. LangExplicit LangSource = iota // LangProject is the language the project recorded. LangProject // LangEnv is GTT_LANG. The locale (LANG, LC_*) is never read: the // output must not depend on the machine it runs on. LangEnv )
type Language ¶ added in v1.8.0
type Language struct {
// contains filtered or unexported fields
}
Language is the interaction language of one invocation. English strings in the code are the keys; a catalog translates them at the output boundary. A string without a translation is shown in English. The zero value and a nil *Language speak English.
func (*Language) Code ¶ added in v1.8.0
Code is the language in force: the first choice by rank, else English.
func (*Language) Set ¶ added in v1.8.0
func (l *Language) Set(from LangSource, code string)
Set records a language choice from one source; "" clears it.
func (*Language) Sprintf ¶ added in v1.8.0
Sprintf translates format before formatting, so its arguments survive. A string argument that is itself a known message is translated too (none, yes, a reason...). A format without a translation is formatted in English and then matched as a whole message (see T).