Documentation
¶
Overview ¶
Package cli holds siding's commands: flags, arguments and output. What a command prints with --json is defined in json.go.
Index ¶
Constants ¶
const ( // CodeInvalidArguments: unknown command, flag or argument. CodeInvalidArguments = fail.InvalidArguments // CodeInternal: an unexpected error without a code of its own. CodeInternal = fail.Internal )
Error codes Execute uses itself; the rest are in package fail.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BuildInfo ¶
BuildInfo describes the running binary.
func CurrentBuild ¶
CurrentBuild returns the BuildInfo of this binary; the commit comes from the VCS stamp Go writes into it.
type Compose ¶
type Compose interface {
Config(ctx context.Context, inv compose.Invocation) ([]byte, error)
UnresolvedConfig(ctx context.Context, inv compose.Invocation) ([]byte, error)
Run(ctx context.Context, inv compose.Invocation, args []string, stdout, stderr io.Writer) error
}
Compose runs docker compose.
type Docker ¶
type Docker interface {
Ping(ctx context.Context) error
Containers(ctx context.Context, labels map[string]string) ([]docker.Container, error)
Container(ctx context.Context, name string) (*docker.Container, error)
Networks(ctx context.Context, labels map[string]string) ([]docker.Network, error)
Volumes(ctx context.Context, labels map[string]string) ([]docker.Volume, error)
EnsureNetwork(ctx context.Context, name string, labels map[string]string) (bool, error)
MemTotal(ctx context.Context) (int64, error)
NetworkGateway(ctx context.Context, name string) (string, error)
NetworkUsers(ctx context.Context, name string) (exists bool, users []string, err error)
RemoveNetwork(ctx context.Context, name string) error
NCPU(ctx context.Context) (int, error)
CreateVolume(ctx context.Context, name string, labels map[string]string) error
RemoveVolume(ctx context.Context, name string) error
VolumeSizes(ctx context.Context) (map[string]int64, error)
RunHelper(ctx context.Context, h docker.Helper) (exit int, output []string, err error)
Logs(ctx context.Context, id string, tail int) ([]string, error)
Stdout(ctx context.Context, id string) ([]string, error)
Memory(ctx context.Context, id string) (uint64, error)
}
Docker reads state from the Docker Engine API.
type Git ¶
type Git interface {
Worktree(ctx context.Context, dir string) (git.Worktree, error)
Top(ctx context.Context, dir string) (string, error)
Tracked(ctx context.Context, top, path string) (bool, error)
Dirty(ctx context.Context, top string) (bool, error)
MergeState(ctx context.Context, r git.Repo, branch string) (git.MergeState, error)
}
Git answers questions about worktrees.
type Options ¶
type Options struct {
Build BuildInfo
// Dir is the current directory.
Dir string
// Home is the user's home directory, for the cache under ~/.siding.
Home string
// Getenv reads an environment variable.
Getenv func(string) string
// OSMachineID returns the operating system's machine id, or "".
OSMachineID func() string
// PID is siding's process id, and Alive reports whether a process still runs (the queue).
PID int
Alive func(pid int) bool
// IsLocalAddress reports whether an IP address belongs to this machine.
IsLocalAddress func(ip string) bool
// Stdin is where questions are answered; IsTerminal reports whether a human is there.
Stdin io.Reader
IsTerminal func() bool
Git Git
Compose Compose
Docker Docker
Probe Prober
Browser Browser
Clock Clock
// Proxy names siding-proxy and its network.
Proxy proxy.Config
}
Options holds everything a command needs from the machine it runs on. Tests pass their own, so no package-level variable is a test seam and tests can run in parallel.
type SystemBrowser ¶
SystemBrowser opens URLs with the platform's opener: open on macOS, $BROWSER (set by VS Code in a devcontainer) or xdg-open on Linux.