cli

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 20 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 command-line interface from the registry: every Spec becomes a cobra subcommand with its flags.

Index

Constants

View Source
const (
	ExitOK       = 0
	ExitInput    = 1 // invalid input
	ExitUsage    = 2 // usage error
	ExitInternal = 3 // internal error
)

Exit codes.

View Source
const DefaultMaxInput = 64 << 20

DefaultMaxInput is the --max-input limit (64 MB).

Variables

This section is empty.

Functions

func ConfigFlag added in v1.1.0

func ConfigFlag(args []string) string

ConfigFlag finds the value of --config in args before cobra parses them: main needs it to know whether to look for plugins.

func Execute

func Execute(args []string, d Deps) int

Execute runs the CLI with args and returns the exit code.

func NewRoot added in v1.0.0

func NewRoot(d Deps) *cobra.Command

NewRoot builds the command tree without running it (cmd/gendocs walks it for the man pages).

Types

type Deps

type Deps struct {
	Registry       *registry.Registry
	Stdin          io.Reader
	Stdout, Stderr io.Writer
	StdinTTY       bool
	StdoutTTY      bool
	Getenv         func(string) string
	RenderStyles   render.Styles
	// LightRenderStyles colour the output when the config says
	// theme = "light"; zero falls back to RenderStyles. The CLI never asks
	// the terminal for its background, so "auto" means dark.
	LightRenderStyles render.Styles
	// TermWidth gives the terminal width for wrapped outputs (Markdown);
	// nil means 80 columns.
	TermWidth func() int
	RunTUI    func(TUIRequest) error // nil: no TUI available
	Clipboard clipboard.Clipboard    // for --copy
	// Plugins found at startup, for "devtooltui plugin list";
	// PluginsOff when the config turned them off.
	Plugins    []plugin.Info
	PluginsOff bool
	// UserConfigDir locates the default config.toml; nil means no default
	// file (tests), only --config or $DEVTOOLTUI_CONFIG.
	UserConfigDir   func() (string, error)
	Version, Commit string
}

Deps is everything the CLI takes from the environment; tests replace it.

type TUIRequest added in v0.2.0

type TUIRequest struct {
	Clipboard bool          // --clipboard
	Config    config.Config // loaded and validated
	Warnings  []string      // config problems, for the statusbar
}

TUIRequest is what the CLI hands to the TUI.

Jump to

Keyboard shortcuts

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