Documentation
¶
Overview ¶
Package cli wires the sjtu command tree. It translates between humans and the internal packages; all protocol and storage knowledge stays below it.
Output contract: command results go to stdout as compact JSON; failures go to stderr as {"error": "<code>", "hint": "<guidance>"}. Exit codes: 0 success, 1 general error, 2 usage error, 3 authentication failure.
Index ¶
Constants ¶
const ( DomainCanvas = daemon.DomainCanvas DomainJAccount = daemon.DomainJAccount )
Credential domains a command failure can blame; the daemon reloads the blamed domain from the credential store and retries the command once.
Variables ¶
var ( Version = "dev" Commit = "unknown" )
Build metadata of the sjtu binary. Release builds inject both via -ldflags "-X .../cli.Version=... -X .../cli.Commit=..." (see .github/workflows/release.yml). A plain `go build` keeps the defaults below.
Functions ¶
func Execute ¶
Execute runs the root command and reports failures to stderr as structured JSON. It returns the process exit code so main stays trivially small.
func ExecuteWith ¶ added in v0.5.0
func ExecuteWith(rt *Runtime, ctx context.Context, args []string, stdout, stderr io.Writer) (int, string)
ExecuteWith runs the command tree against rt and additionally reports the credential domain an auth failure blames (DomainCanvas / DomainJAccount), or "" when the run did not fail on auth. The daemon uses the domain to reload the credential and retry the command once.
Types ¶
type Runtime ¶ added in v0.5.0
type Runtime struct {
// contains filtered or unexported fields
}
Runtime carries the process's shared state: the config and the warm credential sessions. The CLI builds one per process and loads it lazily on first use, so commands that need no credentials (auth, update, help) never touch the store. The daemon shares one Runtime across requests and reloads a domain when its credential dies or is re-issued.
func NewRuntime ¶ added in v0.5.0
func NewRuntime() *Runtime
NewRuntime returns an unloaded Runtime.
func (*Runtime) ReloadDomain ¶ added in v0.5.0
ReloadDomain rebuilds one credential domain from the store after its credential died or was re-issued (the human re-logged in).