Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 40 Imported by: 0

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

View Source
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

View Source
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

func Execute(ctx context.Context, args []string, stdout, stderr io.Writer) int

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) Config added in v0.5.0

func (r *Runtime) Config() (*config.Config, error)

Config returns the loaded configuration.

func (*Runtime) ReloadDomain added in v0.5.0

func (r *Runtime) ReloadDomain(domain string) error

ReloadDomain rebuilds one credential domain from the store after its credential died or was re-issued (the human re-logged in).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL