cli

package module
v0.0.0-...-6f4e670 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 10 Imported by: 5

Documentation

Index

Constants

View Source
const (
	ErrUnsupported = errs.Kind("unsupported")

	ErrParameter = errs.Entity("parameter")
)

Variables

View Source
var (
	ErrInvalidOption     = errors.New("invalid option")
	ErrUnsupportedOption = errors.New("unsupported option")
)
View Source
var ErrUnsupportedParameter = errs.WithDomain(domainErr, ErrUnsupported, ErrParameter)

Functions

func Run

func Run(runner Runner)

func WithExecutors

func WithExecutors[T FlagType](executors map[T]Executor) cfg.Option[Config[T]]

func WithFlag

func WithFlag[T FlagType](flag string, zero T, description string) cfg.Option[Config[T]]

func WithOneOf

func WithOneOf[T FlagType](selectors ...T) cfg.Option[Config[T]]

func WithValidation

func WithValidation[T FlagType](isValid func(*T) error) cfg.Option[Config[T]]

Types

type Config

type Config[T FlagType] struct {
	// contains filtered or unexported fields
}

type Executable

type Executable func(ctx context.Context, logger *slog.Logger, args []string) (int, error)

func (Executable) Exec

func (e Executable) Exec(ctx context.Context, logger *slog.Logger, args []string) (int, error)

type Executor

type Executor interface {
	Exec(ctx context.Context, logger *slog.Logger, args []string) (int, error)
}

type FlagType

type FlagType interface {
	bool | string | int | int64 | uint | uint64 | float64 | time.Duration
}

type Runner

type Runner interface {
	Run(*slog.Logger) (int, error)
}

func NewRunner

func NewRunner[T FlagType](name string, opts ...cfg.Option[Config[T]]) Runner

func NoOp

func NoOp() Runner

type Valuer

type Valuer[T FlagType] func(*flag.FlagSet, string, T, string) *T

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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