command

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

README

command

Go Reference

provides some Command type to parse command line arguments

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCommandNotSet = errors.New("command not set")
)

Functions

This section is empty.

Types

type Command

type Command interface {
	Runnable
	Names
	Info
}

func New

func New(runnable Runnable, fieldOffset, argCountMin, argCountMax int, cmdNamesFold bool, cmdNames ...string) Command

func NewWithRunFunc

func NewWithRunFunc(unmarshalInterface UnmarshalInterface, f RunFunc, fieldOffset, argCountMin, argCountMax int, cmdNamesFold bool, cmdNames ...string) Command

type Handler added in v0.11.0

type Handler struct {
	Unmarshaler              *xstrings.Unmarshaler
	FieldNameBeginsLowerCase bool
	FieldNameFold            bool
	FieldTagKey              string
}

func (*Handler) Find added in v0.11.0

func (h *Handler) Find(cmds []Command, args ...string) (int, error)

func (*Handler) FindAndUnmarshal added in v0.11.0

func (h *Handler) FindAndUnmarshal(cmds []Command, args ...string) (Command, error)

func (*Handler) FindCmd added in v0.11.0

func (h *Handler) FindCmd(cmds []Command, args ...string) (Command, error)

func (*Handler) ParameterUsage added in v0.11.0

func (h *Handler) ParameterUsage(cmd Command) (string, error)

func (*Handler) Unmarshal added in v0.11.0

func (h *Handler) Unmarshal(cmd Command, args ...string) error

func (*Handler) Usage added in v0.11.0

func (h *Handler) Usage(cmd Command, cmdName string, prefix string) (string, error)

type Info

type Info interface {
	FieldOffset() int
	ArgCountMin() int
	ArgCountMax() int
}

type Names

type Names interface {
	CmdNames() []string
	CmdNamesFold() bool
	Is(cmdName string) bool
}

func NewNames

func NewNames(cmdNamesFold bool, cmdNames ...string) Names

type RunFunc

type RunFunc func(ctx context.Context) error

type Runnable

type Runnable interface {
	Run(ctx context.Context) error
}

func NewRunnable

func NewRunnable(unmarshalInterface UnmarshalInterface, f RunFunc) Runnable

type UnknownCommandError

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

func (*UnknownCommandError) Error

func (e *UnknownCommandError) Error() string

func (*UnknownCommandError) Name

func (e *UnknownCommandError) Name() string

func (*UnknownCommandError) Unwrap

func (e *UnknownCommandError) Unwrap() error

type UnmarshalInterface

type UnmarshalInterface interface{}

Jump to

Keyboard shortcuts

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