cli

package
v0.0.0-...-e64b6cb Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Args

type Args []string

func (Args) Arg

func (args Args) Arg(i int) string

func (Args) Eq

func (args Args) Eq(v int) (err error)

func (Args) Max

func (args Args) Max(v int) (err error)

func (Args) Min

func (args Args) Min(v int) (err error)

func (Args) Range

func (args Args) Range(min, max int) (err error)

func (Args) ShiftN

func (args Args) ShiftN(n int) (v []string, rights Args, err error)

type Command

type Command struct {
	Name        string
	Usage       string
	Description string

	New       func(ctx *CommandContext) (err error)
	Help      func(ctx *CommandContext) (err error)
	Run       func(ctx *CommandContext) (err error)
	ParseArgs func(ctx *CommandContext) (err error)
	// contains filtered or unexported fields
}

func (*Command) Parse

func (b *Command) Parse(ctx *CommandContext) (_ *CommandContext, err error)

func (*Command) Sub

func (b *Command) Sub(cmd *Command) *Command

type CommandContext

type CommandContext struct {
	Out,
	Err io.Writer

	Context   context.Context
	InputArgs []string
	Args      Args
	NamedArgs any
	// contains filtered or unexported fields
}

func (*CommandContext) Cmd

func (ctx *CommandContext) Cmd() *Command

func (*CommandContext) Flags

func (ctx *CommandContext) Flags() *flag.FlagSet

func (*CommandContext) Fork

func (ctx *CommandContext) Fork() *CommandContext

func (*CommandContext) FullName

func (ctx *CommandContext) FullName() string

func (*CommandContext) Help

func (ctx *CommandContext) Help() (err error)

func (*CommandContext) Name

func (ctx *CommandContext) Name() string

func (*CommandContext) Parent

func (ctx *CommandContext) Parent() *CommandContext

func (*CommandContext) Path

func (ctx *CommandContext) Path() []string

func (*CommandContext) Run

func (ctx *CommandContext) Run() error

func (*CommandContext) Value

func (ctx *CommandContext) Value(name any) any

func (*CommandContext) WithValue

func (ctx *CommandContext) WithValue(name, value any) *CommandContext

type ContextExecuteError

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

func NewContextExecuteError

func NewContextExecuteError(ctx *CommandContext, err error) *ContextExecuteError

func ToContextExecuteError

func ToContextExecuteError(ctx *CommandContext, err error) (e *ContextExecuteError)

func (*ContextExecuteError) Ctx

func (*ContextExecuteError) Error

func (c *ContextExecuteError) Error() string

func (*ContextExecuteError) Unwrap

func (c *ContextExecuteError) Unwrap() error

type ContextParserError

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

func NewContextParserError

func NewContextParserError(ctx *CommandContext, event string, err error) *ContextParserError

func ToContextParserError

func ToContextParserError(ctx *CommandContext, event string, err error) (e *ContextParserError)

func (*ContextParserError) Ctx

func (*ContextParserError) Error

func (c *ContextParserError) Error() string

func (*ContextParserError) Unwrap

func (c *ContextParserError) Unwrap() error

type Helper

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

func Help

func Help(ctx *CommandContext) *Helper

func (*Helper) Execute

func (h *Helper) Execute() (err error)

func (*Helper) SubCommands

func (h *Helper) SubCommands(subCommands bool) *Helper

func (*Helper) WithSubCommands

func (h *Helper) WithSubCommands() *Helper

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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