cli

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Overview

Package cli wires the monorel CLI commands.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is set at build time via -ldflags. Defaults to "dev" for `go run` / `go install` invocations.

Functions

func Execute

func Execute() error

Execute runs the monorel CLI. Returns the first non-nil error from command resolution or execution; main() prints and sets the exit code.

func ExitCode added in v0.2.0

func ExitCode(err error) int

ExitCode reports the exit code an error should map to. Returns 0 for nil, the wrapped int for any error chain containing ErrExit (so callers can wrap-and-still-propagate), and 1 otherwise. main() calls this to set os.Exit.

func IsSilentExit added in v0.2.0

func IsSilentExit(err error) bool

IsSilentExit reports whether the error chain contains an ErrExit. main() uses this to skip the default "Error: ..." stderr print for errors that are exit-code-only (validate's --strict path emits one).

Types

type ErrExit added in v0.2.0

type ErrExit int

ErrExit is a sentinel error wrapping a non-zero exit code. main() uses the wrapped value as the process exit code and suppresses the "Error: ..." stderr line that a plain error would produce.

Cobra normally renders RunE errors; SilenceErrors on root suppresses that, and main inspects the error to set os.Exit. Existing convention in this repo: every command returns plain errors. validate is the first command that wants a specific non-1 exit code (2 for --strict warnings), so we introduce the wrapper here.

func (ErrExit) Error added in v0.2.0

func (e ErrExit) Error() string

Error returns a stable string form. Satisfies the error interface; main() doesn't print this. See ExitCode and IsSilentExit.

type Runtime

type Runtime struct {
	// ConfigPath is the absolute path to monorel.toml.
	ConfigPath string

	// RepoDir is the directory that contains monorel.toml. Treated
	// as the repository root for git invocations and the parent of
	// .changeset/.
	RepoDir string

	// Config is the parsed monorel.toml.
	Config *config.Config

	// Repo is a git.Repo bound to RepoDir.
	Repo git.Repo

	// Changesets are pending changesets loaded from .changeset/.
	Changesets []*changeset.Changeset

	// Tags is every tag in the repository.
	Tags []string

	// PreState is the pre-release-mode state loaded from
	// .changeset/pre.json, or nil when not in pre-release mode.
	// Read-only; pre subcommands construct their own to write.
	PreState *changeset.PreState

	// ChangesetDir is the absolute path to .changeset/. The pre and
	// release commands write/delete files here.
	ChangesetDir string

	// Log is the CLI logger. Use this for all user-facing output.
	// Info / debug routes to the cobra command's stdout; warn /
	// error / fatal routes to its stderr.
	Log *loglayer.LogLayer
}

Runtime is the shared state that read-only commands (plan, status, preview) compute by combining monorel.toml + .changeset/*.md + git tags. Constructed via [loadRuntime].

Jump to

Keyboard shortcuts

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