Help us shape the future of Go! Take the 2026 Go Developer Survey

cli

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package cli is the gotools command line on urfave/cli v3: an App with one entry point, Run(ctx, args), that serves the commands declared in package command.

The App turns each command's declaration (name, summary, prose, examples, flags) into a urfave/cli command and its help, hands the command a Context built from the App's streams, environment and seams, and runs its PreRun, Run and PostRun. Nothing here is global, so a test builds its own App with in-memory streams and fakes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Program string // the name used in usage text, e.g. "gotools"
	Version string

	Stdin          io.Reader // os.Stdin when nil
	Stdout, Stderr io.Writer // os.Stdout and os.Stderr when nil
	Environ        []string  // NAME=value pairs; os.Environ when nil
	WorkDir        string    // os.Getwd when empty
	Go             gocmd.Runner

	// Commands are the commands served; command.All when nil.
	Commands []command.Command
	// contains filtered or unexported fields
}

App is the command line. The zero value of every field but Program has a default.

func (*App) Has

func (a *App) Has(name string) bool

Has reports whether the App serves a command called name, or an alias of it.

func (*App) Report

func (a *App) Report(err error) int

Report prints err in the house style (a "❌" line on stderr) and returns the exit code: 0 for nil, the error's own code, or 1.

func (*App) Run

func (a *App) Run(ctx context.Context, args []string) error

Run is the entry point. args excludes the program name. A failure comes back as an error, usually an *errors.Error carrying the exit code; Report turns it into output and that code.

Jump to

Keyboard shortcuts

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