cli

package
v0.0.0-...-a3b5a27 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 7 Imported by: 2

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
)

Functions

func Parse

func Parse() error

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(command *Command)

Help prints out registered commands for app

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(context.Context)
	Init func(context.Context) error
	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