cli

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLogger = errors.New("cli: invalid logger specified")

ErrInvalidLogger is returned by WithLogger when a nil *slog.Logger is supplied.

View Source
var ErrUnknownType = fmt.Errorf("unknown type")

Functions

func As

func As[T any](in any) T

func Children

func Children(children ...*cobra.Command) opt.Option[*Command]

func Feat

func Feat() opt.Option[*Command]

QG-065: Feat() intentionally minimal; expansion tracked separately.

func Hide

func Hide() opt.Option[*Command]

func Parent

func Parent(p *cobra.Command) opt.Option[*Command]

func SetArgs

func SetArgs(flags *pflag.FlagSet, prefix string, args Args) error

func WithArgs

func WithArgs(prefix string, a Args) opt.Option[*Command]

func WithLogger

func WithLogger(l *slog.Logger) opt.Option[*Command]

Types

type Arg

type Arg struct {
	Short       string `json:"short" yaml:"short"` // one-letter abbreviated flag
	Value       any    `json:"value" yaml:"value"`
	Deprecated  bool   `json:"deprecated" yaml:"deprecated"`
	Replacement string `json:"replacement" yaml:"replacement"`
	Description string `json:"description" yaml:"description"`
	Required    bool   `json:"required" yaml:"required"`
	GetFN       func() any
}

func (*Arg) String

func (a *Arg) String() string

type Args

type Args map[string]*Arg

func (Args) Get

func (a Args) Get(key string) any

type Command

type Command struct {
	*cobra.Command

	Args Args
	Docs Docs
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(
	docs Docs,
	exec Execute,
	opts ...opt.Option[*Command],
) (*Command, error)

func (*Command) LogValue

func (c *Command) LogValue() slog.Value

type Docs

type Docs struct {
	Name  string `json:"name" yaml:"name"`
	Usage string `json:"usage" yaml:"usage"`
	Short string `json:"short_desc" yaml:"short_desc"`
	Desc  string `json:"desc" yaml:"desc"`
}

type Execute

type Execute func(*cobra.Command, []string) error

Jump to

Keyboard shortcuts

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