Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultHelpFormatter(item *HelpItem, formatting *HelpFormatting) string
- func Help[T any](target *T, formatter FormatterFn) (string, error)
- func HelpDefault[T any](target *T) (string, error)
- func Parse[T any](target *T, rawArgs ...string) (trailing []string, err error)
- func StringReflect(field reflect.StructField, fieldValue reflect.Value, values []string) (int, error)
- func ValueFromString(fieldType reflect.Type, inputs []string) (*reflect.Value, int, error)
- type ArgsParser
- type ArgsState
- type FormatterFn
- type HelpFormatting
- type HelpItem
- type MandatoryParameterError
- type ParseError
- type Tag
- type TagType
- type UnsupportedReflectTypeError
Constants ¶
View Source
const (
TagName = "clapper"
)
Variables ¶
View Source
var ( ErrNoStruct = errors.New("target is not a struct") ErrEmptyArgument = errors.New("empty argument") ErrUnexpectedValue = errors.New("expected flag not value") ErrFieldCanNotBeSet = errors.New("field can't be set") ErrNoFlagSpecifier = errors.New("no flag specified for struct field") ErrShortOverrideCanOnlyBeOneLetter = errors.New("short override can only be one letter") ErrLongMustBeMoreThanOne = errors.New("long name must be more than one character") )
Functions ¶
func DefaultHelpFormatter ¶
func DefaultHelpFormatter(item *HelpItem, formatting *HelpFormatting) string
func HelpDefault ¶
func StringReflect ¶
Types ¶
type ArgsParser ¶
type ArgsParser struct {
Params map[string][]string
Trailing []string
// contains filtered or unexported fields
}
func NewArgsParser ¶
func NewArgsParser() *ArgsParser
func (*ArgsParser) Add ¶
func (pa *ArgsParser) Add(arg string) error
func (*ArgsParser) Parse ¶
func (pa *ArgsParser) Parse(args []string) (*ArgsParser, error)
func (*ArgsParser) PopTrailing ¶
func (pa *ArgsParser) PopTrailing(took int) *ArgsParser
func (*ArgsParser) ValuesEqualWith ¶
func (pa *ArgsParser) ValuesEqualWith(other *ArgsParser) bool
func (*ArgsParser) With ¶
func (pa *ArgsParser) With(modifier func(args *ArgsParser)) *ArgsParser
type FormatterFn ¶
type FormatterFn = func(item *HelpItem, formatting *HelpFormatting) string
type HelpFormatting ¶
func DefaultHelpFormatting ¶
func DefaultHelpFormatting() *HelpFormatting
func (*HelpFormatting) Update ¶
func (h *HelpFormatting) Update(item *HelpItem) *HelpFormatting
type HelpItem ¶
func HelpItemFromTags ¶
func (*HelpItem) Display ¶
func (h *HelpItem) Display(formatting HelpFormatting) string
type MandatoryParameterError ¶
type MandatoryParameterError struct {
Name string
}
func NewMandatoryParameterError ¶
func NewMandatoryParameterError(name string) MandatoryParameterError
func (MandatoryParameterError) Error ¶
func (e MandatoryParameterError) Error() string
type ParseError ¶
type ParseError struct {
Index int
Name string
TagLine string
// contains filtered or unexported fields
}
func NewParseError ¶
func NewParseError(from error, index int, name string, tagLine string) ParseError
func (ParseError) Error ¶
func (e ParseError) Error() string
func (ParseError) Underlying ¶
func (e ParseError) Underlying() error
type Tag ¶
func (*Tag) DeriveName ¶
type UnsupportedReflectTypeError ¶
type UnsupportedReflectTypeError struct {
Type string
}
func NewUnsupportedReflectTypeError ¶
func NewUnsupportedReflectTypeError(t string) UnsupportedReflectTypeError
func (UnsupportedReflectTypeError) Error ¶
func (e UnsupportedReflectTypeError) Error() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.