flags

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMarhsallerNotImplemented = fmt.Errorf("MarshalFlags function not implemented")

Functions

func AddFlags

func AddFlags(into Mut, flags Map) (err error)

Types

type Context

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

type DefaulSerializer

type DefaulSerializer struct{}

func (DefaulSerializer) SerializeFlags

func (d DefaulSerializer) SerializeFlags(val interface{}, into *ErrMut) (err error)

type ErrMut

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

func (*ErrMut) BoolFlagIf

func (e *ErrMut) BoolFlagIf(prefix string, mode Mode, b bool)

func (*ErrMut) LongBoolFlag

func (e *ErrMut) LongBoolFlag(prefix string, b bool)

func (*ErrMut) SetBoolFlag

func (e *ErrMut) SetBoolFlag(prefix string, mode Mode)

func (*ErrMut) SetFlag

func (e *ErrMut) SetFlag(prefix Flag, value string)

func (*ErrMut) SetLongBoolFlag

func (e *ErrMut) SetLongBoolFlag(prefix string)

func (*ErrMut) SetLongFlag

func (e *ErrMut) SetLongFlag(prefix string, value string)

func (*ErrMut) SetShortBoolFlag

func (e *ErrMut) SetShortBoolFlag(prefix string)

func (*ErrMut) SetShortFlag

func (e *ErrMut) SetShortFlag(prefix string, value string)

func (*ErrMut) ShortBoolFlag

func (e *ErrMut) ShortBoolFlag(prefix string, b bool)

type Flag

type Flag struct {
	Prefix string
	Mode   Mode
	Value  ValueKind
}

func BoolFlag

func BoolFlag(prefix string, mode Mode) (f Flag)

func LongPrefix

func LongPrefix(prefix string) (f Flag)

func ShortPrefix

func ShortPrefix(prefix string) (f Flag)

type Formatter

type Formatter interface {
	FormatFlags(flags Map) (formatted string, err error)
	JoinFlags(flags []string) (joined string, err error)
}

type Manager

type Manager struct {
	Formatter  Formatter
	Serializer Serializer
	Context    Context
}

func (*Manager) NewFlags

func (fm *Manager) NewFlags() (e *ErrMut)

type Map

type Map map[Flag]string

type Marshaller

type Marshaller interface {
	MarshalFlags(into *ErrMut) (err error)
}

type Mode

type Mode int
const (
	ModeShort Mode = iota
	ModeLong
)

type Mut

type Mut interface {
	SetFlag(prefix Flag, value string) (err error)
}

type SerializeCtx

type SerializeCtx struct {
	Serializer Serializer
	Into       *ErrMut
}

type SerializeFn

type SerializeFn func(ctx SerializeCtx) (err error)

type Serializer

type Serializer interface {
	SerializeFlags(val interface{}, into *ErrMut) (err error)
}

type SerializerFns

type SerializerFns map[interface{}]SerializeFn

type Serializers

type Serializers map[reflect.Type]SerializeFn

type TypeSerialize

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

func (TypeSerialize) SerializeFlags

func (t TypeSerialize) SerializeFlags(val interface{}, into *ErrMut) (err error)

type ValueKind

type ValueKind int
const (
	ValueString ValueKind = iota
	ValueBool
)

Jump to

Keyboard shortcuts

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