clivar

package
v0.0.131 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package clivar provides syntactic sugar for working with the flag package. Allows you to describe using structure tags how to use flag to fill in this structure.

Index

Constants

View Source
const (
	TagCliExample             = "NAME[description key]:valueType=defaultValue"
	CountPartsTagData         = 2
	CountPartsNameType        = 2
	CountPartsNameDescription = 2
)
View Source
const (
	ValueTypeString       = "string"
	ValueTypeInt          = "int"
	ValueTypeFloat64      = "float64"
	ValueTypeBool         = "bool"
	ValueTypeSliceStrings = "SliceStrings"
)

Variables

This section is empty.

Functions

func Load

func Load(structData interface{}) error

Load field of target struct from flag like described in tags

func NewTagProcessor

func NewTagProcessor() refavour.TagProcessor

Types

type CliVar

type CliVar struct {
	Key          string
	Description  string
	DefaultValue interface{}
}

CliVar describe tag for struct receiver

func (*CliVar) GetBool

func (cli *CliVar) GetBool() *bool

GetBool read bool value from flag

func (*CliVar) GetFloat64

func (cli *CliVar) GetFloat64() *float64

GetFloat64 read float64 value from flag

func (*CliVar) GetInt

func (cli *CliVar) GetInt() *int

GetInt read int value from flag

func (*CliVar) GetString

func (cli *CliVar) GetString() *string

GetString read string value from flag

type FieldInfo added in v0.0.47

type FieldInfo struct {
	Type         reflect.Type
	Name         string
	ValueType    string
	DefaultValue string
	Description  string
}

type SliceStrings added in v0.0.104

type SliceStrings []string // separator = ","

type TagInfo added in v0.0.47

type TagInfo struct {
	Tag string
}

func (*TagInfo) GetFieldInfo added in v0.0.47

func (tag *TagInfo) GetFieldInfo(typeField reflect.StructField, valueField reflect.Value) (interface{}, error)

Jump to

Keyboard shortcuts

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