cli

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BoolVar        = flag.BoolVar
	DurationVar    = flag.DurationVar
	Int64Var       = flag.Int64Var
	IntVar         = flag.IntVar
	StringVar      = flag.StringVar
	Uint64Var      = flag.Uint64Var
	UintVar        = flag.UintVar
	StringSliceVar = flag.StringSliceVar

	BoolVarP        = flag.BoolVarP
	DurationVarP    = flag.DurationVarP
	Int64VarP       = flag.Int64VarP
	IntVarP         = flag.IntVarP
	StringVarP      = flag.StringVarP
	Uint64VarP      = flag.Uint64VarP
	UintVarP        = flag.UintVarP
	StringSliceVarP = flag.StringSliceVarP

	PrintDefaults = flag.PrintDefaults
)

Flag variable binding functions from spf13/pflag.

Functions

func ParseWithFlagSet

func ParseWithFlagSet(fs *flag.FlagSet, args []string) error

ParseWithFlagSet parses flags and environment variables for a scoped FlagSet.

Types

type App

type App struct {
	Name string
	// contains filtered or unexported fields
}

App is the cli entrypoint.

func NewApp

func NewApp(name string) *App

NewApp creates a new App instance.

func (*App) AddCommand

func (app *App) AddCommand(name, title string, constructor func() *Command)

AddCommand adds a command to the app.

func (*App) Help

func (app *App) Help()

Help prints out registered commands for app.

func (*App) HelpCommand

func (app *App) HelpCommand(fs *flag.FlagSet, command *Command)

HelpCommand prints out help for a specific command.

func (*App) Run

func (app *App) Run() error

Run passes os.Args without the command name to RunWithArgs().

func (*App) RunWithArgs

func (app *App) RunWithArgs(args []string) error

RunWithArgs is a cli entrypoint which sets up a cancellable context for the command.

type Command

type Command struct {
	Name, Title string

	Bind func(*flag.FlagSet)
	Run  func(context.Context, []string) error
}

Command is an individual command

type CommandInfo

type CommandInfo struct {
	Name  string
	Title string
	New   func() *Command
}

CommandInfo is the constructor info for a command

Jump to

Keyboard shortcuts

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