flagset

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SplitAndTrim

func SplitAndTrim(input string) (ret []string)

SplitAndTrim splits input separated by a comma and trims excessive white space from the substrings.

Types

type BigIntFlag

type BigIntFlag struct {
	Name    string
	Usage   string
	Value   *big.Int
	Group   string
	Default *big.Int
}

func (*BigIntFlag) Set

func (b *BigIntFlag) Set(value string) error

func (*BigIntFlag) String

func (b *BigIntFlag) String() string

func (*BigIntFlag) UpdateValue

func (b *BigIntFlag) UpdateValue(value string)

type BoolFlag

type BoolFlag struct {
	Name    string
	Usage   string
	Default bool
	Value   *bool
	Group   string
}

func (*BoolFlag) UpdateValue

func (b *BoolFlag) UpdateValue(value string)

type ByName

type ByName []*FlagVar

ByName implements sort.Interface for []*FlagVar based on the Name field.

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type DurationFlag

type DurationFlag struct {
	Name    string
	Usage   string
	Value   *time.Duration
	Default time.Duration
	Group   string
}

func (*DurationFlag) UpdateValue

func (d *DurationFlag) UpdateValue(value string)

type FlagVar

type FlagVar struct {
	Name    string
	Usage   string
	Group   string
	Default any
	Value   Updatable
}

type Flagset

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

func NewFlagSet

func NewFlagSet(name string) *Flagset

func (*Flagset) Args

func (f *Flagset) Args() []string

func (*Flagset) BigIntFlag

func (f *Flagset) BigIntFlag(b *BigIntFlag)

func (*Flagset) BoolFlag

func (f *Flagset) BoolFlag(b *BoolFlag)

func (*Flagset) DurationFlag

func (f *Flagset) DurationFlag(d *DurationFlag)

func (*Flagset) Float64Flag

func (f *Flagset) Float64Flag(i *Float64Flag)

func (*Flagset) GetAllFlags

func (f *Flagset) GetAllFlags() []string

func (*Flagset) Help

func (f *Flagset) Help() string

func (*Flagset) IntFlag

func (f *Flagset) IntFlag(i *IntFlag)

func (*Flagset) MapStringFlag

func (f *Flagset) MapStringFlag(m *MapStringFlag)

func (*Flagset) MarkDown

func (f *Flagset) MarkDown() string

MarkDown implements cli.MarkDown interface

func (*Flagset) Parse

func (f *Flagset) Parse(args []string) error

func (*Flagset) SliceStringFlag

func (f *Flagset) SliceStringFlag(s *SliceStringFlag)

func (*Flagset) StringFlag

func (f *Flagset) StringFlag(b *StringFlag)

func (*Flagset) Uint64Flag

func (f *Flagset) Uint64Flag(i *Uint64Flag)

func (*Flagset) UpdateValue

func (f *Flagset) UpdateValue(names []string, values []string)

UpdateValue updates the underlying value of a flag given the flag name and value to update using pointer.

func (*Flagset) Visit

func (f *Flagset) Visit() ([]string, []string)

Visit visits all the set flags and returns the name and value in string to set later.

type Float64Flag

type Float64Flag struct {
	Name    string
	Usage   string
	Value   *float64
	Default float64
	Group   string
}

func (*Float64Flag) UpdateValue

func (f *Float64Flag) UpdateValue(value string)

type IntFlag

type IntFlag struct {
	Name    string
	Usage   string
	Value   *int
	Default int
	Group   string
}

func (*IntFlag) UpdateValue

func (b *IntFlag) UpdateValue(value string)

type MapStringFlag

type MapStringFlag struct {
	Name    string
	Usage   string
	Value   *map[string]string
	Group   string
	Default map[string]string
}

func (*MapStringFlag) Set

func (m *MapStringFlag) Set(value string) error

func (*MapStringFlag) String

func (m *MapStringFlag) String() string

func (*MapStringFlag) UpdateValue

func (m *MapStringFlag) UpdateValue(value string)

type SliceStringFlag

type SliceStringFlag struct {
	Name    string
	Usage   string
	Value   *[]string
	Default []string
	Group   string
}

func (*SliceStringFlag) Set

func (i *SliceStringFlag) Set(value string) error

func (*SliceStringFlag) String

func (i *SliceStringFlag) String() string

func (*SliceStringFlag) UpdateValue

func (i *SliceStringFlag) UpdateValue(value string)

type StringFlag

type StringFlag struct {
	Name               string
	Usage              string
	Default            string
	Value              *string
	Group              string
	HideDefaultFromDoc bool
}

func (*StringFlag) UpdateValue

func (b *StringFlag) UpdateValue(value string)

type Uint64Flag

type Uint64Flag struct {
	Name    string
	Usage   string
	Value   *uint64
	Default uint64
	Group   string
}

func (*Uint64Flag) UpdateValue

func (b *Uint64Flag) UpdateValue(value string)

type Updatable

type Updatable interface {
	UpdateValue(string)
}

Updatable is a minimalistic representation of a flag which has the method `UpdateValue` implemented which can be called while overwriting flags.

Jump to

Keyboard shortcuts

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