argument

package
v0.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BOOLEANVALUE_BOOL          = BooleanValue{BOOLEANTYPE_BOOL, "true", "false"}
	BOOLEANVALUE_BOOLUPPER     = BooleanValue{BOOLEANTYPE_BOOLUPPER, "True", "False"}
	BOOLEANVALUE_BOOLUPPERFULL = BooleanValue{BOOLEANTYPE_BOOLUPPERFULL, "TRUE", "FALSE"}
	BOOLEANVALUE_INTEGER       = BooleanValue{BOOLEANTYPE_INTEGER, "1", "0"}
)
View Source
var (
	BOOLEANTYPE_UNDEFINED     = BooleanType{""}
	BOOLEANTYPE_BOOL          = BooleanType{"bool"}
	BOOLEANTYPE_BOOLUPPER     = BooleanType{"boolupper"}
	BOOLEANTYPE_BOOLUPPERFULL = BooleanType{"boolupperfull"}
	BOOLEANTYPE_INTEGER       = BooleanType{"integer"}
	BOOLEANTYPE_CUSTOM        = BooleanType{"custom"}
)
View Source
var (
	TYPE_UNDEFINED = Type{""}
	TYPE_BOOLEAN   = Type{"boolean"}
	TYPE_STRING    = Type{"string"}
	TYPE_INTEGER   = Type{"integer"}
	TYPE_FLOAT     = Type{"float"}
	TYPE_ENUM      = Type{"enum"}
	TYPE_BASE      = Type{"base"}
	TYPE_CONNECT   = Type{"connect"}
)
View Source
var (
	SEPERATOR_SPACE = newSpaceSeperator()
)

Functions

This section is empty.

Types

type Argument

type Argument interface {
	GetType() Type
	IsMandatory() bool
	IsDisabled() bool
	Disable()
	Enable()
	GetSeperator(Seperator) Seperator
	GetArgument() string
	GetName() string
	Parse(Seperator) (string, error)
	NormalizeState()
	ValidateLazy() error
	Reset()
}

type ArgumentWithNumberValue

type ArgumentWithNumberValue[T NumberValue] interface {
	ArgumentWithValue[T]
	GetMinValue() T
	GetMaxValue() T
}

type ArgumentWithValue

type ArgumentWithValue[T any] interface {
	Argument
	GetDefault() T
	GetValue() T
}

type Arguments

type Arguments struct {
	Seperator *Seperator `json:"seperator,omitempty" yaml:"seperator,omitempty"`
	Arguments []Argument `json:"items,omitempty" yaml:"items,omitempty"`
}

func (Arguments) Equal

func (left Arguments) Equal(right Arguments) bool

func (*Arguments) NormalizeState

func (arguments *Arguments) NormalizeState()

func (*Arguments) Parse

func (arguments *Arguments) Parse() (args []string, err error)

func (*Arguments) UnmarshalJSON

func (arguments *Arguments) UnmarshalJSON(data []byte) (err error)

func (*Arguments) UnmarshalYAML

func (arguments *Arguments) UnmarshalYAML(value *yaml.Node) (err error)

TODO YAML and JSON unmarshl can be unified in one function by using their Decode interfaces we need to declare a new interface Decode and assign it the decode functions --> then YAML and JSON Decoder implement that interface and it can be given as input to the function function: unmarshl(Argument, Decoder) (Argument, err)

func (*Arguments) ValidateLazy

func (arguments *Arguments) ValidateLazy() (err error)

type Base

type Base struct {
	Type      Type       `json:"type" yaml:"type"`
	Mandatory bool       `json:"mandatory" yaml:"mandatory"`
	Disabled  bool       `json:"disabled" yaml:"disabled"`
	Seperator *Seperator `json:"seperator,omitempty" yaml:"seperator,omitempty"`
	Argument  string     `json:"argument" yaml:"argument"`
	Name      string     `json:"name" yaml:"name"`
}

func (*Base) Disable

func (argument *Base) Disable()

func (*Base) Enable

func (argument *Base) Enable()

func (*Base) GetArgument

func (argument *Base) GetArgument() string

func (*Base) GetName

func (argument *Base) GetName() string

func (*Base) GetSeperator

func (argument *Base) GetSeperator(seperator Seperator) (sep Seperator)

func (*Base) GetType

func (argument *Base) GetType() Type

func (*Base) IsDisabled

func (argument *Base) IsDisabled() bool

func (*Base) IsMandatory

func (argument *Base) IsMandatory() bool

func (*Base) NormalizeState

func (argument *Base) NormalizeState()

func (*Base) Parse

func (argument *Base) Parse(sep Seperator) (string, error)

func (*Base) Reset

func (argument *Base) Reset()

func (*Base) ValidateLazy

func (argument *Base) ValidateLazy() (err error)

type Boolean

type Boolean struct {
	Base    `yaml:",inline"`
	Default bool          `json:"default" yaml:"default"`
	Value   bool          `json:"value" yaml:"value"`
	Values  *BooleanValue `json:"values" yaml:"values"`
}

func (*Boolean) GetDefault

func (argument *Boolean) GetDefault() bool

func (*Boolean) GetValue

func (argument *Boolean) GetValue() bool

func (*Boolean) NormalizeState

func (argument *Boolean) NormalizeState()

func (*Boolean) Parse

func (argument *Boolean) Parse(sep Seperator) (arg string, err error)

func (*Boolean) Reset

func (argument *Boolean) Reset()

func (*Boolean) ValidateLazy

func (argument *Boolean) ValidateLazy() (err error)

type BooleanType

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

func BooleanTypeFromString

func BooleanTypeFromString(s string) (BooleanType, error)

func (BooleanType) MarshalJSON

func (t BooleanType) MarshalJSON() ([]byte, error)

func (BooleanType) String

func (t BooleanType) String() string

func (*BooleanType) UnmarshalJSON

func (t *BooleanType) UnmarshalJSON(data []byte) (err error)

func (*BooleanType) UnmarshalYAML

func (t *BooleanType) UnmarshalYAML(value *yaml.Node) (err error)

type BooleanValue

type BooleanValue struct {
	Type  BooleanType `json:"type" yaml:"type"`
	True  string      `json:"true" yaml:"true"`
	False string      `json:"false" yaml:"false"`
}

type Connect

type Connect struct {
	Type     Type   `json:"type" yaml:"type"`
	Argument string `json:"argument" yaml:"argument"`
}

func (*Connect) Disable

func (argument *Connect) Disable()

func (*Connect) Enable

func (argument *Connect) Enable()

func (*Connect) GetArgument

func (argument *Connect) GetArgument() string

func (*Connect) GetName

func (argument *Connect) GetName() string

func (*Connect) GetSeperator

func (argument *Connect) GetSeperator(seperator Seperator) (sep Seperator)

func (*Connect) GetType

func (argument *Connect) GetType() Type

func (*Connect) IsDisabled

func (argument *Connect) IsDisabled() bool

func (*Connect) IsMandatory

func (argument *Connect) IsMandatory() bool

func (*Connect) NormalizeState

func (argument *Connect) NormalizeState()

func (*Connect) Parse

func (argument *Connect) Parse(sep Seperator) (string, error)

func (*Connect) ParseWithIP

func (argument *Connect) ParseWithIP(ip string) (string, error)

func (*Connect) Reset

func (argument *Connect) Reset()

func (*Connect) ValidateLazy

func (argument *Connect) ValidateLazy() (err error)

type Enum

type Enum struct {
	Base  `yaml:",inline"`
	Value string     `json:"value" yaml:"value"`
	Items []EnumItem `json:"items" yaml:"items"`
}

func (*Enum) Equal

func (left *Enum) Equal(right *Enum) bool

func (*Enum) GetDefault

func (argument *Enum) GetDefault() string

func (*Enum) GetValue

func (argument *Enum) GetValue() string

func (*Enum) NormalizeState

func (argument *Enum) NormalizeState()

func (*Enum) Parse

func (argument *Enum) Parse(sep Seperator) (arg string, err error)

func (*Enum) Reset

func (argument *Enum) Reset()

func (*Enum) ValidateLazy

func (argument *Enum) ValidateLazy() (err error)

type EnumItem

type EnumItem struct {
	Name    string `json:"name" yaml:"name"`
	Value   string `json:"value" yaml:"value"`
	Default bool   `json:"default,omitempty" yaml:"default,omitempty"`
}

type Float

type Float struct {
	Base     `yaml:",inline"`
	Default  float32 `json:"default" yaml:"default"`
	Value    float32 `json:"value" yaml:"value"`
	MinValue float32 `json:"minvalue" yaml:"minvalue"`
	MaxValue float32 `json:"maxvalue" yaml:"maxvalue"`
}

func (*Float) GetDefault

func (argument *Float) GetDefault() float32

func (*Float) GetMaxValue

func (argument *Float) GetMaxValue() float32

func (*Float) GetMinValue

func (argument *Float) GetMinValue() float32

func (*Float) GetValue

func (argument *Float) GetValue() float32

func (*Float) NormalizeState

func (argument *Float) NormalizeState()

func (*Float) Parse

func (argument *Float) Parse(sep Seperator) (arg string, err error)

func (*Float) Reset

func (argument *Float) Reset()

func (*Float) ValidateLazy

func (argument *Float) ValidateLazy() (err error)

type Integer

type Integer struct {
	Base     `yaml:",inline"`
	Default  int `json:"default" yaml:"default"`
	Value    int `json:"value" yaml:"value"`
	MinValue int `json:"minvalue" yaml:"minvalue"`
	MaxValue int `json:"maxvalue" yaml:"maxvalue"`
}

func (*Integer) GetDefault

func (argument *Integer) GetDefault() int

func (*Integer) GetMaxValue

func (argument *Integer) GetMaxValue() int

func (*Integer) GetMinValue

func (argument *Integer) GetMinValue() int

func (*Integer) GetValue

func (argument *Integer) GetValue() int

func (*Integer) NormalizeState

func (argument *Integer) NormalizeState()

func (*Integer) Parse

func (argument *Integer) Parse(sep Seperator) (arg string, err error)

func (*Integer) Reset

func (argument *Integer) Reset()

func (*Integer) ValidateLazy

func (argument *Integer) ValidateLazy() (err error)

type NumberValue

type NumberValue interface {
	int | float32
}

type Seperator

type Seperator struct {
	Arguments     *string `json:"arguments,omitempty" yaml:"arguments,omitempty"`
	ArgumentValue *string `json:"argumentvalue,omitempty" yaml:"argumentvalue,omitempty"`
}

type String

type String struct {
	Base    `yaml:",inline"`
	Default string `json:"default" yaml:"default"`
	Value   string `json:"value" yaml:"value"`
}

func (*String) GetDefault

func (argument *String) GetDefault() string

func (*String) GetValue

func (argument *String) GetValue() string

func (*String) NormalizeState

func (argument *String) NormalizeState()

func (*String) Parse

func (argument *String) Parse(sep Seperator) (arg string, err error)

func (*String) Reset

func (argument *String) Reset()

func (*String) ValidateLazy

func (argument *String) ValidateLazy() (err error)

type Type

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

func TypeFromString

func TypeFromString(s string) (Type, error)

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

func (Type) String

func (t Type) String() string

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(data []byte) (err error)

func (*Type) UnmarshalYAML

func (t *Type) UnmarshalYAML(value *yaml.Node) (err error)

Jump to

Keyboard shortcuts

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