cli

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 54 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 builds the cobra command tree and maps errors to exit codes.

Index

Constants

View Source
const (
	AnnotationFormats   = "formats"      // --format values the command accepts; empty means it ignores --format
	AnnotationFailOn    = "fail-on"      // --fail-on values
	AnnotationExitCodes = "exit-codes"   // exit codes the command returns
	AnnotationRelated   = "docs.related" // site paths of related guides and concepts
	AnnotationWrites    = "docs.writes"  // the stores the command writes to, such as S3; unset when it writes nothing
)

Command annotations that scripts/gendocs reads. Values are comma-separated lists.

View Source
const (
	ExitOK          = 0
	ExitError       = 1
	ExitUsage       = 2
	ExitFindings    = 3 // --fail-on matched
	ExitAuth        = 4
	ExitInterrupted = 130
)

Exit codes. ExitCodes describes each one for the docs site.

Variables

This section is empty.

Functions

func Execute

func Execute(ctx context.Context, d *app.Deps, args []string) int

Execute runs the command line in args (without the program name) and returns the exit code.

func FlagKeys added in v0.6.0

func FlagKeys() map[string]string

FlagKeys maps each flag that sets a config key to that key.

func Main added in v0.2.0

func Main(ctx context.Context, d *app.Deps, args []string) int

Main is Execute for a whole process. It also answers carapace's completion requests, which changes package-level state, so in-process tests call Execute instead.

func NewRootCmd

func NewRootCmd(d *app.Deps) *cobra.Command

NewRootCmd returns the full command tree. scripts/gendocs uses it.

func Run

func Run(ctx context.Context, args []string, stdout, stderr io.Writer) int

Run is the process entry point. args includes the program name, as os.Args does.

func ServeMCP

func ServeMCP(
	ctx context.Context,
	d *app.Deps,
	args []string,
	serve func(context.Context, *mcpkit.Server) error,
) error

ServeMCP runs `relgap mcp args...` but hands the server to serve instead of serving stdio, so tests can connect an in-process client.

func SplitAnnotation added in v0.6.0

func SplitAnnotation(cmd *cobra.Command, key string) []string

SplitAnnotation returns the list in annotation key of cmd, or nil when it is unset or empty.

Types

type ExitCode added in v0.6.0

type ExitCode struct {
	Code int
	Name string
	Desc string
}

ExitCode is one exit code and what it means.

func ExitCodes added in v0.6.0

func ExitCodes() []ExitCode

ExitCodes returns every exit code in ascending order.

Jump to

Keyboard shortcuts

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