cli

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 45 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cli holds terrace's commands: each parses its command line, calls one operation, and writes the result.

Index

Constants

View Source
const LoginsEvery = time.Minute

LoginsEvery is how often home reads the accounts' logins again, so one signed in elsewhere shows as it is.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, root *cobra.Command, args []string, show Shower) int

Execute runs root on args, shows any error through show, the one renderer of errors, and returns the process's exit status (3.5): by the outcome a command printed, else by the error's kind, whatever returned it, and 130 for an interrupt.

func NewRootCommand

func NewRootCommand(deps Deps) *cobra.Command

NewRootCommand builds the command tree.

Types

type Deps

type Deps struct {
	Version string
	// Launcher starts runs and their processes, for plan, apply and destroy.
	Launcher Launcher
	// Records opens a repo's kept runs, for the commands that take a code.
	Records Records
	// Process runs a run in the process launched for it.
	Process Process
	// Lists gathers what output, ls and accounts print.
	Lists Lists
	// Getwd is the folder the command runs in.
	Getwd func() (string, error)
	// Claude are the person's and the machine's Claude Code settings files,
	// which may undo terrace's hook.
	Claude claudecode.Machine
	// Git tells the hook which guarded files a git command would change.
	Git Git
	// Home is the person's home folder, which ~ names.
	Home string
	// Now is the wall clock; its zone is the one times are given in.
	Now func() time.Time
	// Terminals are which of stdin and stdout are terminals.
	Terminals Terminals
	// Profiles reads the AWS config, for the login command a held click
	// gives; nil gives none.
	Profiles Profiles
	// SignIns starts the delete sign-in's device sign-ins, for a run's
	// view in the person's terminal; nil starts none.
	SignIns SignIns
	// Terminated is ctx, ended too as the process is sent SIGTERM or
	// SIGHUP, which the lists take as an interrupt; nil ends it no more.
	// A start and a run's process don't: a run outlives what started it.
	Terminated func(ctx context.Context) (context.Context, context.CancelFunc)
	// Screen is the terminal stdout is, for a run's view; nil where it's
	// none.
	Screen Screen
	// Getenv reads the environment's colour and terminal settings: NO_COLOR,
	// FORCE_COLOR, COLORTERM, TERM, COLORFGBG and HOME. nil reads none.
	Getenv func(string) string
}

Deps is what the commands need, built once by run.

type Git

type Git interface {
	GitCommits
	GitFiles
}

Git answers the hook's questions of a work tree, as git.Client does: of its commits, and of its files.

type GitCommits

type GitCommits interface {
	Differs(ctx context.Context, dir, rng string, specs []string) ([]string, error)
	Changed(ctx context.Context, dir, rev string, specs []string) ([]string, error)
	Tree(ctx context.Context, dir, rev string, specs []string) ([]string, error)
	IsCommit(ctx context.Context, dir, rev string) (bool, error)
	Rebases(ctx context.Context, dir, rev string) (bool, error)
}

GitCommits answers the hook's questions of a work tree's commits: which guarded files differ across a range, from a commit to the work tree, or in a commit of its own, whether a name is a commit, and whether a pull onto a branch rebases.

type GitFiles

type GitFiles interface {
	Unstaged(ctx context.Context, dir string, specs []string) ([]string, error)
	Untracked(ctx context.Context, dir string, specs []string) ([]string, error)
	Others(ctx context.Context, dir string, specs []string) ([]string, error)
	Tracks(ctx context.Context, dir, spec string) (bool, error)
	Applies(ctx context.Context, dir, patch string) ([]string, error)
}

GitFiles answers the hook's questions of a work tree's files: those that change from the index, those git doesn't track, or ignores too, whether it tracks a path, and those a patch touches.

type Launcher

type Launcher interface {
	Launch(ctx context.Context, in start.Input) (record.RunState, error)
}

Launcher starts a run and its process, as launch.Launcher does.

type Lists

type Lists interface {
	Outputs(ctx context.Context, in start.SurveyInput) (lists.Listing[terragrunt.UnitOutputs], error)
	Units(ctx context.Context, in start.SurveyInput) (lists.Listing[lists.Unit], error)
	Accounts(ctx context.Context, cwd string) ([]lists.Account, error)
	Estate(ctx context.Context, cwd string) (lists.Estate, error)
	Logins(ctx context.Context, e lists.Estate) ([]lists.Account, error)
}

Lists gathers what the lists print that no run holds, as lists.Lister does.

type Process

type Process interface {
	Run(ctx context.Context, o launch.Opening, lease uintptr) error
}

Process runs a run in the process launched for it, as launch.Process does, its lease on the file lease.

type Profiles

type Profiles interface {
	Profile(ctx context.Context, name config.ProfileName) (cloud.Profile, bool, error)
}

Profiles reads what the AWS config says of a profile, as the cloud does.

type Records

type Records interface {
	Open(ctx context.Context, cwd string) (runs.Repo, error)
	Locate(ctx context.Context, cwd string) (runs.Repo, error)
}

Records opens a repo's kept runs from a folder in it, or locates the repo alone, as runs.Opener does.

type Screen

type Screen interface {
	Size() (cols, rows int)
	Foreground() bool
	OpenKeys(ask terminal.Ask) (terminal.KeySource, error)
	// Background is the terminal's background, asked alone, its keys read
	// only for the answer.
	Background(ctx context.Context) (ink.RGB, bool, error)
	TakeStops() terminal.StopSource
}

Screen is the terminal a run's view draws on, as terminal.Screen gives it: its size and whether the process is in its foreground, the keys typed at it, the terminal asked what ask says as they're opened, and the person's Ctrl-Z, nil where the process started with it ignored.

type Shower

type Shower struct {
	Stderr io.Writer
	// Zone is the zone the times of the run in the way are given in.
	Zone *time.Location
	// Profiles reads the AWS config, for the login command a held click in
	// the run in the way gives; nil gives none.
	Profiles Profiles
}

Shower is the one renderer of the error a command ends with: in text on Stderr, "terrace: <message>" and its next steps, or, for a command run with --json, as its error document on the command's stdout (3.4.16).

func ShowError

func ShowError(w io.Writer, profiles Profiles) Shower

ShowError is a Shower to w, in the local zone, reading profiles.

func (Shower) JSON

func (s Shower) JSON(ctx context.Context, w io.Writer, err error)

JSON shows err as its error document on w (3.4.1). Where the run in it can't be written, the document goes without it; where nothing can be written, err goes to Stderr in text, and the write's error after it.

func (Shower) Text

func (s Shower) Text(err error)

Text shows err in text.

type SignIns

type SignIns interface {
	StartSignIn(ctx context.Context, name config.ProfileName) (cloud.DeviceSignIn, error)
}

SignIns starts the delete sign-in's device sign-ins, as the cloud does.

type Terminals

type Terminals struct {
	Stdin, Stdout bool
}

Terminals are which of the command's stdin and stdout are terminals.

Jump to

Keyboard shortcuts

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