cli

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

Package cli contains common command-line flags and configuration options.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExitVersion is an error indicating the application should exit after
	// showing version.
	ErrExitVersion = errors.New("version flag exit")
	// ErrArgsNeeded is an error indicating the application needed some additional
	// flags or arguments passed to continue.
	ErrArgsNeeded = errors.New("additional flags or arguments needed")
)

Functions

func Run added in v0.3.0

func Run(err error)

Run is a helper that wraps a call to function that implements main in a program, and if error returned is not nil, it prints the error message (if error is printable) and exits with code 1.

Types

type App added in v0.3.0

type App struct {
	Name        string        // Name of the application.
	Description string        // Description of the application.
	ArgsUsage   string        // Usage message for the command-line arguments.
	Flags       *flag.FlagSet // Command-line flags.
}

App represents a command-line application.

func (*App) HandleStartup added in v0.3.0

func (a *App) HandleStartup(args []string, stdout, stderr io.Writer) error

HandleStartup handles the command startup. All exported fields shouldn't be modified after HandleStartup is called.

It sets up the command-line flags, parses the arguments, and handles the version flag if specified.

Jump to

Keyboard shortcuts

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