Documentation
¶
Overview ¶
Package cli wires the monorel CLI commands.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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
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
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.
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].