cli

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error added in v0.1.2

func Error(msg string)

func Fatal added in v0.1.2

func Fatal(msg string)

func GetBool

func GetBool(args Args, name string) bool

func GetInt

func GetInt(args Args, name string) (int, error)

func GetString

func GetString(args Args, name string) string

func Info added in v0.1.12

func Info(msg string)

func IsJSON

func IsJSON(args Args) bool

func IsTTY added in v0.6.1

func IsTTY() bool

func Run added in v0.6.1

func Run(app *App) error

func RunApp

func RunApp(app *App) error

func Success added in v0.1.12

func Success(msg string)

Types

type App

type App struct {
	Name        string
	Description string
	Args        []ArgDef
	Flags       []FlagDef
	GlobalFlags []FlagDef
	Subcommands []*SubcommandDef
	ActionFunc  func(Args)
}

func Action

func Action(app *App, handler func(Args)) *App

func AddFlag

func AddFlag(app *App, name string, description string, defaultValue string) *App

func Arg

func Arg(app *App, name string, description string) *App

func Description

func Description(app *App, desc string) *App

func GlobalFlag

func GlobalFlag(app *App, name string, desc string, defaultValue string) *App

func New

func New(name string) *App

func WithCommands added in v0.6.1

func WithCommands(app *App, cmds ...*SubcommandDef) *App

type ArgDef

type ArgDef struct {
	Name        string
	Description string
}

type Args

type Args struct {
	// contains filtered or unexported fields
}

func NewArgs

func NewArgs(values map[string]string) Args

func (Args) Context added in v0.6.1

func (args Args) Context() context.Context

func (Args) Respond added in v0.6.1

func (args Args) Respond(data any)

type FlagDef

type FlagDef struct {
	Name         string
	Description  string
	DefaultValue string
}

type SubcommandDef

type SubcommandDef struct {
	Name        string
	Description string
	Args        []ArgDef
	Flags       []FlagDef
	ActionFunc  func(Args)
}

func NewCommand added in v0.6.1

func NewCommand(name string, desc string) *SubcommandDef

func (*SubcommandDef) Action added in v0.6.1

func (cmd *SubcommandDef) Action(handler func(Args)) *SubcommandDef

func (*SubcommandDef) Arg added in v0.6.1

func (cmd *SubcommandDef) Arg(name string, description string) *SubcommandDef

func (*SubcommandDef) Flag added in v0.6.1

func (cmd *SubcommandDef) Flag(name string, desc string, defaultValue string) *SubcommandDef

Jump to

Keyboard shortcuts

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