values

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultValue

func DefaultValue(v flag.Value) string

func IsBool

func IsBool(v flag.Value) bool

IsBool checks if a given value is a bool value, i.e. implements the BoolValued interface

func SetFromEnv

func SetFromEnv(into flag.Value, envVars string) bool

SetFromEnv fills a value from a list of env vars

Types

type BoolValue

type BoolValue bool

BoolValue is a flag.Value type holding boolean values

func NewBool

func NewBool(into *bool, v bool) *BoolValue

NewBool creates a new bool value

func (*BoolValue) IsBoolFlag

func (bo *BoolValue) IsBoolFlag() bool

IsBoolFlag returns true

func (*BoolValue) IsDefault

func (bo *BoolValue) IsDefault() bool

IsDefault return true if the bool value is false

func (*BoolValue) Set

func (bo *BoolValue) Set(s string) error

Set sets the value from a provided string

func (*BoolValue) String

func (bo *BoolValue) String() string

type BoolValued

type BoolValued interface {
	flag.Value
	// IsBoolFlag should return true to indicate that this value is a bool value
	IsBoolFlag() bool
}

BoolValued is an interface values can implement to indicate that they are a bool option, i.e. can be set without providing a value with just -f for example

type DefaultValued

type DefaultValued interface {
	// IsDefault should return true if the value stored is the default value, and thus does not need be shown in the help message
	IsDefault() bool
}

DefaultValued in an interface to determine if the value stored is the default value, and thus does not need be shown in the help message

type Float64Value

type Float64Value float64

Float64Value is a flag.Value type holding int values

func NewFloat64

func NewFloat64(into *float64, v float64) *Float64Value

NewFloat64 creates a new int value

func (*Float64Value) Set

func (ia *Float64Value) Set(s string) error

Set sets the value from a provided string

func (*Float64Value) String

func (ia *Float64Value) String() string

type Floats64Value

type Floats64Value []float64

Floats64Value is a flag.Value type holding int values

func NewFloats64

func NewFloats64(into *[]float64, v []float64) *Floats64Value

NewFloats64 creates a new multi-int value

func (*Floats64Value) Clear

func (ia *Floats64Value) Clear()

Clear clears the slice

func (*Floats64Value) IsDefault

func (ia *Floats64Value) IsDefault() bool

IsDefault return true if the int slice is empty

func (*Floats64Value) Set

func (ia *Floats64Value) Set(s string) error

Set sets the value from a provided string

func (*Floats64Value) String

func (ia *Floats64Value) String() string

type IntValue

type IntValue int

IntValue is a flag.Value type holding int values

func NewInt

func NewInt(into *int, v int) *IntValue

NewInt creates a new int value

func (*IntValue) Set

func (ia *IntValue) Set(s string) error

Set sets the value from a provided string

func (*IntValue) String

func (ia *IntValue) String() string

type IntsValue

type IntsValue []int

IntsValue is a flag.Value type holding int values

func NewInts

func NewInts(into *[]int, v []int) *IntsValue

NewInts creates a new multi-int value

func (*IntsValue) Clear

func (ia *IntsValue) Clear()

Clear clears the slice

func (*IntsValue) IsDefault

func (ia *IntsValue) IsDefault() bool

IsDefault return true if the int slice is empty

func (*IntsValue) Set

func (ia *IntsValue) Set(s string) error

Set sets the value from a provided string

func (*IntsValue) String

func (ia *IntsValue) String() string

type MultiValued

type MultiValued interface {
	flag.Value
	// Clear should clear the list of values
	Clear()
}

MultiValued is an interface ti indicate that a value can hold multiple values

type StringValue

type StringValue string

StringValue is a flag.Value type holding string values

func NewString

func NewString(into *string, v string) *StringValue

NewString creates a new string value

func (*StringValue) IsDefault

func (sa *StringValue) IsDefault() bool

IsDefault return true if the string value is empty

func (*StringValue) Set

func (sa *StringValue) Set(s string) error

Set sets the value from a provided string

func (*StringValue) String

func (sa *StringValue) String() string

type StringsValue

type StringsValue []string

StringsValue is a flag.Value type holding string slices values

func NewStrings

func NewStrings(into *[]string, v []string) *StringsValue

NewStrings creates a new multi-string value

func (*StringsValue) Clear

func (sa *StringsValue) Clear()

Clear clears the slice

func (*StringsValue) IsDefault

func (sa *StringsValue) IsDefault() bool

IsDefault return true if the string slice is empty

func (*StringsValue) Set

func (sa *StringsValue) Set(s string) error

Set sets the value from a provided string

func (*StringsValue) String

func (sa *StringsValue) String() string

Jump to

Keyboard shortcuts

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