Documentation ¶
Index ¶
- Constants
- Variables
- func IsPointer(a any) bool
- func MatchAndSetField(structPtr any, tree *Tree, args *[]string) (nextStruct any, err error)
- func OptFatal(v ...any)
- func RunAfter(i any) error
- func RunBefore(i any) error
- func RunRun(i any) error
- func SetValueInStruct[T any](vStruct reflect.Value, key string, value T) bool
- func ToAny(i any) any
- type Afterer
- type Beforer
- type BuilderOptions
- type FieldInfo
- type FieldKind
- type FieldOpt
- type Getter
- type Input
- type Runner
- type Setter
- type Stringify
- type Tree
- type UnsafeSetter
- type Unsetter
- type Validater
- type ValueKindGetter
Constants ¶
View Source
const ( UnknownStr = "Unknown" ArgumentStr = "Argument" OptionStr = "Option" CommandStr = "Command" ParentStr = "Parent" )
View Source
const ( TagMsg = "msg" TagOpt = "opt" TagRename = "rename" )
Tags is a list of tags used in this package.
View Source
const DiffFromValueKind = 200
View Source
const NumberKinds = 4
Argument, Option, Command, Parent
Variables ¶
Functions ¶
func MatchAndSetField ¶
func SetValueInStruct ¶
Types ¶
type BuilderOptions ¶
func (BuilderOptions) String ¶
func (b BuilderOptions) String() string
type FieldInfo ¶
type FieldInfo struct { Field *refl.StructField Index int Name string Kind FieldKind KindIndex int InnerType refl.Type Message string Opt FieldOpt Usage string }
FieldInfo holds information about a field in a opter struct.
func (*FieldInfo) IsInnerTypeHelp ¶
type FieldKind ¶
type FieldKind int
const ( UnknownKind FieldKind = iota + DiffFromValueKind ArgumentKind OptionKind CommandKind ParentKind )
Field kind
func FieldKindFromString ¶
func (FieldKind) KindIndexKey ¶
type FieldOpt ¶
type FieldOpt struct {
// contains filtered or unexported fields
}
FieldOpt is an information of FieldInfo struct.
func ParseTagOpt ¶
type Getter ¶
type Getter[T constraints.InputType] interface { Get() T }
type Input ¶
type Input[T constraints.InputType] struct { // contains filtered or unexported fields }
type Setter ¶
type Setter[T constraints.InputType] interface { Set(value T) }
type Tree ¶
type Tree struct { Arguments []*FieldInfo Options map[string]*FieldInfo Commands map[string]*FieldInfo Required map[*FieldInfo]bool // contains filtered or unexported fields }
Tree is for parsing and matching arguments. It also helps to generate help message.
func MakeTree ¶
func MakeTree(structPtr any, parent any, options BuilderOptions) (tree *Tree, err error)
func NewTree ¶
func NewTree(options BuilderOptions) *Tree
func Parse ¶
func Parse(structPtr any, args []string, options BuilderOptions) (tree *Tree, err error)
func (*Tree) BuilderOptions ¶
func (tree *Tree) BuilderOptions() BuilderOptions
type UnsafeSetter ¶
type UnsafeSetter interface {
UnsafeSet(value any)
}
type ValueKindGetter ¶
Click to show internal directories.
Click to hide internal directories.