option

package
v0.0.0-...-17ed7cf Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ParsableTypes = []Type{Int, UInt, Float, Bool}

Functions

func GetIndexOutside

func GetIndexOutside(wholeString, toEscapeStart, toEscapeEnd, toFind string) (int, error)

func IsArray

func IsArray(rawValue string) bool

func IsStruct

func IsStruct(rawValue string) bool

func Parse

func Parse(rawValue string, valueType Type) (any, error)

func UnwrapArray

func UnwrapArray(rawValue string) []string

Types

type Option

type Option struct {
	Name           string
	DefaultValue   any
	Type           Type
	Optional       bool
	PossibleValues []string
	Options        []Option
}

func AppendOptions

func AppendOptions(originalOptions []Option, rawOptions string) ([]Option, error)

func Compare

func Compare(userInput []string, realOptions []Option) ([]Option, error)

Compare checks if raw array of strings e.g. "name=Linus,lastname=Torvalds" are applicable into rule's set of options e.g. {name?:string,lastname:int=0} Returns user modified array of options

func GetOption

func GetOption(rawOptions string) (Option, string, error)

func ParseOptions

func ParseOptions(rawOptions string) ([]Option, error)

func (*Option) SetValue

func (o *Option) SetValue(rawValue string) error

type Type

type Type uint
const (
	Any Type = iota
	Int
	UInt
	Float
	String
	Bool
	List
	Struct
	Enum
	Unknown
)

func FromString

func FromString(rawType string) Type

func GetOptionType

func GetOptionType(rawType string) (Type, []string, error)

func GetType

func GetType(rawValue any) Type

func GetValueAndType

func GetValueAndType(rawValue string) (any, Type)

func (Type) ToString

func (t Type) ToString() string

Jump to

Keyboard shortcuts

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