cli

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Success exit code.
	Success int = 0

	// Failure exit code.
	Failure int = 1
)

Variables

View Source
var (
	// InfoLog log.
	InfoLog = log.New(os.Stdout, Cyan("INFO\t"), log.Ldate|log.Ltime)

	// ErrorLog log.
	ErrorLog = log.New(os.Stderr, Red("ERROR\t"), log.Ldate|log.Ltime|log.Lshortfile)
)
View Source
var (
	// ErrMissingArguments error.
	ErrMissingArguments = errors.New("cli: missing arguments")
)

Functions

func Blue

func Blue(text string) string

Blue function.

func Cyan

func Cyan(text string) string

Cyan function.

func Gray

func Gray(text string) string

Gray function.

func Green

func Green(text string) string

Green function.

func Purple

func Purple(text string) string

Purple function.

func Red

func Red(text string) string

Red function.

func White

func White(text string) string

White function.

func Yellow

func Yellow(text string) string

Yellow function.

Types

type App

type App struct {
	Name       string
	Version    string
	TryDefault bool
	Groups     []*Group
}

App type.

func (*App) Execute

func (a *App) Execute()

Execute function.

func (*App) PrintHelp

func (a *App) PrintHelp() int

PrintHelp function.

type Command

type Command struct {
	Name       string
	Usage      string
	Arguments  []string
	HandleFunc func(group *Group, command *Command, arguments []string) int
	// contains filtered or unexported fields
}

Command type.

func (*Command) FlagSet

func (c *Command) FlagSet() *flag.FlagSet

FlagSet function.

func (*Command) Parse

func (c *Command) Parse(arguments []string) ([]string, error)

Parse function.

func (*Command) PrintError added in v1.2.1

func (c *Command) PrintError(err error) int

PrintError function.

func (*Command) PrintHelp

func (c *Command) PrintHelp(group *Group) int

PrintHelp function.

type Group

type Group struct {
	Name     string
	Usage    string
	Commands []*Command
}

Group type.

func (*Group) PrintHelp

func (g *Group) PrintHelp() int

PrintHelp function.

type Table

type Table struct {
	Headers []string
	Rows    [][]string
}

Table type.

func (*Table) Create

func (t *Table) Create() []string

Create function.

func (*Table) Print

func (t *Table) Print() int

Print function.

Jump to

Keyboard shortcuts

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