flag

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package flag extends the stdlib flag package, adding support for checked values.

Index

Constants

This section is empty.

Variables

View Source
var (
	ContinueOnError = flag.ContinueOnError
	ExitOnError     = flag.ExitOnError
	PanicOnError    = flag.PanicOnError
)

Aliases for the flag.ErrorHandling values.

Functions

This section is empty.

Types

type ErrorHandling

type ErrorHandling = flag.ErrorHandling

ErrorHandling aliases the flag.ErrorHandling type.

type Flag

type Flag = flag.Flag

Flag aliases the flag.Flag type.

type FlagSet

type FlagSet struct {
	*flag.FlagSet
}

FlagSet extends the flag.FlagSet type, adding support for checked flag values. Its flag definition methods behave in the same way as those of flag.FlagSet, with the addition of a final variadic parameter that can be used to add value checks to the flag.

func NewFlagSet

func NewFlagSet(name string, errorHandling flag.ErrorHandling) *FlagSet

NewFlagSet creates a new extended FlagSet.

func (*FlagSet) Duration

func (f *FlagSet) Duration(name string, value time.Duration, usage string, checks ...value.CheckFunc[time.Duration]) *time.Duration

Duration behaves as flag.FlagSet.Duration, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) DurationVar

func (f *FlagSet) DurationVar(p *time.Duration, name string, value time.Duration, usage string, checks ...value.CheckFunc[time.Duration])

DurationVar behaves as flag.FlagSet.DurationVar, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Float64 added in v0.3.0

func (f *FlagSet) Float64(name string, value float64, usage string, checks ...value.CheckFunc[float64]) *float64

Float64 behaves as flag.FlagSet.Float64, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Float64Var added in v0.3.0

func (f *FlagSet) Float64Var(p *float64, name string, value float64, usage string, checks ...value.CheckFunc[float64])

Float64Var behaves as flag.FlagSet.Float64Var, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Int

func (f *FlagSet) Int(name string, value int, usage string, checks ...value.CheckFunc[int]) *int

Int behaves as flag.FlagSet.Int, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Int64 added in v0.3.0

func (f *FlagSet) Int64(name string, value int64, usage string, checks ...value.CheckFunc[int64]) *int64

Int64 behaves as flag.FlagSet.Int64, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Int64Var added in v0.3.0

func (f *FlagSet) Int64Var(p *int64, name string, value int64, usage string, checks ...value.CheckFunc[int64])

Int64Var behaves as flag.FlagSet.Int64Var, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) IntVar

func (f *FlagSet) IntVar(p *int, name string, value int, usage string, checks ...value.CheckFunc[int])

IntVar behaves as flag.FlagSet.IntVar, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) String

func (f *FlagSet) String(name string, value string, usage string, checks ...value.CheckFunc[string]) *string

String behaves as flag.FlagSet.String, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) StringVar

func (f *FlagSet) StringVar(p *string, name string, value string, usage string, checks ...value.CheckFunc[string])

StringVar behaves as flag.FlagSet.StringVar, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Uint added in v0.3.0

func (f *FlagSet) Uint(name string, value uint, usage string, checks ...value.CheckFunc[uint]) *uint

Uint behaves as flag.FlagSet.Uint, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Uint64 added in v0.3.0

func (f *FlagSet) Uint64(name string, value uint64, usage string, checks ...value.CheckFunc[uint64]) *uint64

Uint64 behaves as flag.FlagSet.Uint64, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) Uint64Var added in v0.3.0

func (f *FlagSet) Uint64Var(p *uint64, name string, value uint64, usage string, checks ...value.CheckFunc[uint64])

Uint64Var behaves as flag.FlagSet.Uint64Var, with an additional variadic parameter allowing checks to be applied to the parsed value.

func (*FlagSet) UintVar added in v0.3.0

func (f *FlagSet) UintVar(p *uint, name string, value uint, usage string, checks ...value.CheckFunc[uint])

UintVar behaves as flag.FlagSet.UintVar, with an additional variadic parameter allowing checks to be applied to the parsed value.

type Value

type Value = flag.Value

Value aliases the flag.Value type.

Jump to

Keyboard shortcuts

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