cli

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 49 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 implements the otag command line.

Index

Constants

View Source
const (
	ExitOK        = 0
	ExitError     = 1
	ExitUsage     = 2
	ExitRetryable = 75 // EX_TEMPFAIL: safe to retry
)

Exit codes.

View Source
const EnvelopeVersion = 1

EnvelopeVersion is the version of the --json output envelope.

Variables

This section is empty.

Functions

func Main

func Main(ctx context.Context, args []string, env Env) int

Main runs the CLI and returns the process exit code.

Types

type Build

type Build struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	Date    string `json:"date"`
}

Build identifies the binary. The release build injects it with -ldflags (-X main.version, main.commit, main.date); ResolveBuild fills the gaps for builds without ldflags such as `go install`.

func ResolveBuild

func ResolveBuild(b Build) Build

ResolveBuild replaces unset build values (empty, "dev", "none", "unknown") with what runtime/debug.ReadBuildInfo knows: the module version of a `go install pkg@version` build and the VCS revision and time of a local build.

func (Build) String

func (b Build) String() string

type Env

type Env struct {
	Stdin          io.Reader // hook payloads (`otag event`)
	Stdout, Stderr io.Writer
	Getenv         func(string) string
	// Environ lists the environment (for prefix matches such as LC_*); nil = the
	// variable names of os.Environ, looked up through Getenv.
	Environ func() []string
	Cwd     string
	// Build identifies the binary for `otag version`; see ResolveBuild.
	Build Build
	// Terminal reports whether stdin and stdout are a terminal (nil: check the files).
	Terminal func() bool
	// contains filtered or unexported fields
}

Env is the process environment the CLI runs in; injected for tests.

Jump to

Keyboard shortcuts

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