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

cli

package
v0.1.0-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package cli implements the operator command set behind cmd/sigil: contract export, migration status, planning, apply and SQL export, deployment diagnostics and bounded expired-row cleanup. It is an operator tool, never a runtime component, and it never serves authentication traffic.

The package is embeddable so a host that compiles its own plugins can build an operator binary that sees them: construct a Tool with the host's plugin definitions and call Run from main. The API is experimental until the alpha release stabilizes it.

No command prints a connection string, a secret value or a driver error. Database failures are reported through the documented storage diagnostics and the PostgreSQL server log holds the details.

Index

Constants

View Source
const (
	ExitOK      = 0 // success; for status and check, the schema is current and nothing failed
	ExitFailure = 1 // the operation failed or a finding needs operator investigation
	ExitUsage   = 2 // unknown command, flag or plugin
	ExitPending = 3 // nothing is broken, but migrations must be applied (status, check, cleanup)
)

Process exit codes shared by every command.

View Source
const (
	DatabaseEnv = "SIGIL_DATABASE_URL" // connection string when --database is absent
	SecretEnv   = "SIGIL_SECRET"       // default deployment secret checked by sigil check
)

Environment variables the tool reads. Their values are never printed.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct {
	Definition plugin.Definition
	Prune      func(ctx context.Context, store storage.Store, before time.Time, limit int) (int64, error)
}

Plugin is a compiled plugin the tool knows. Its Definition supplies the --plugin identifier, the contract and the schema declarations; it needs no bound runtime and its handlers are never invoked. Prune, when set, removes the plugin's expired rows during cleanup with the same bounds as the core pruner; it must never remove a row that could still authenticate.

type Tool

type Tool struct {
	Plugins []Plugin
	Version string              // build identifier printed by version; "dev" when empty
	Getenv  func(string) string // environment lookup; os.Getenv when nil
}

Tool is the operator command set over a fixed set of known plugins. The zero value knows no plugins and reads the process environment.

func (Tool) Run

func (t Tool) Run(args []string, stdout, stderr io.Writer) int

Run executes one command and returns its process exit code.

func (Tool) RunContext

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

RunContext is Run under a caller-owned context, so an interrupted operator command cancels its transaction instead of leaving a lock behind.

Jump to

Keyboard shortcuts

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