flags

package
v0.0.0-...-b4aeae5 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package flags contains enhanced versions of spf13/pflag flag routines which will read from the environment also.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolP

func BoolP(name, shorthand string, value bool, usage string, groups string) (out *bool)

BoolP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.BoolP

func BoolVarP

func BoolVarP(flags *pflag.FlagSet, p *bool, name, shorthand string, value bool, usage string, groups string)

BoolVarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.BoolVarP

func CountP

func CountP(name, shorthand string, usage string, groups string) (out *int)

CountP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.CountP

func CountVarP

func CountVarP(flags *pflag.FlagSet, p *int, name, shorthand string, usage string, groups string)

CountVarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.CountVarP

func DurationP

func DurationP(name, shorthand string, value time.Duration, usage string, groups string) (out *time.Duration)

DurationP defines a flag which can be set by an environment variable

It wraps the duration in an fs.Duration for extra suffixes and passes it to pflag.VarP

func DurationVarP

func DurationVarP(flags *pflag.FlagSet, p *time.Duration, name, shorthand string, value time.Duration, usage string, groups string)

DurationVarP defines a flag which can be set by an environment variable

It wraps the duration in an fs.Duration for extra suffixes and passes it to pflag.VarP

func FVarP

func FVarP(flags *pflag.FlagSet, value pflag.Value, name, shorthand, usage string, groups string)

FVarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.VarP

func Float64P

func Float64P(name, shorthand string, value float64, usage string, groups string) (out *float64)

Float64P defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.Float64P

func Float64VarP

func Float64VarP(flags *pflag.FlagSet, p *float64, name, shorthand string, value float64, usage string, groups string)

Float64VarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.Float64VarP

func Int64P

func Int64P(name, shorthand string, value int64, usage string, groups string) (out *int64)

Int64P defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.IntP

func Int64VarP

func Int64VarP(flags *pflag.FlagSet, p *int64, name, shorthand string, value int64, usage string, groups string)

Int64VarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.Int64VarP

func IntP

func IntP(name, shorthand string, value int, usage string, groups string) (out *int)

IntP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.IntP

func IntVarP

func IntVarP(flags *pflag.FlagSet, p *int, name, shorthand string, value int, usage string, groups string)

IntVarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.IntVarP

func SetDefaultFromEnv

func SetDefaultFromEnv(flags *pflag.FlagSet, name string)

SetDefaultFromEnv constructs a name from the flag passed in and sets the default from the environment if possible

Used to create backend flags like --skip-links

func StringArrayP

func StringArrayP(name, shorthand string, value []string, usage string, groups string) (out *[]string)

StringArrayP defines a flag which can be set by an environment variable

It sets one value only - command line flags can be used to set more.

It is a thin wrapper around pflag.StringArrayP

func StringArrayVarP

func StringArrayVarP(flags *pflag.FlagSet, p *[]string, name, shorthand string, value []string, usage string, groups string)

StringArrayVarP defines a flag which can be set by an environment variable

It sets one value only - command line flags can be used to set more.

It is a thin wrapper around pflag.StringArrayVarP

func StringP

func StringP(name, shorthand string, value string, usage string, groups string) (out *string)

StringP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.StringP

func StringVarP

func StringVarP(flags *pflag.FlagSet, p *string, name, shorthand string, value string, usage string, groups string)

StringVarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.StringVarP

func Uint32VarP

func Uint32VarP(flags *pflag.FlagSet, p *uint32, name, shorthand string, value uint32, usage string, groups string)

Uint32VarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.Uint32VarP

func VarP

func VarP(value pflag.Value, name, shorthand, usage string, groups string)

VarP defines a flag which can be set by an environment variable

It is a thin wrapper around pflag.VarP

Types

type Group

type Group struct {
	Groups *Groups
	Name   string
	Help   string
	Flags  *pflag.FlagSet
}

Group related flags together for documentation purposes

func (*Group) Add

func (g *Group) Add(flag *pflag.Flag)

Add a new flag to the Group

type Groups

type Groups struct {
	// Groups of flags
	Groups []*Group

	// GroupsMaps maps a group name to a Group
	ByName map[string]*Group
}

Groups of Flags

var All *Groups

All is the global stats Groups

func NewGroups

func NewGroups() *Groups

NewGroups constructs a collection of Groups

func (*Groups) AllRegistered

func (gs *Groups) AllRegistered() map[*pflag.Flag]struct{}

AllRegistered returns all flags in a group

func (*Groups) Filter

func (gs *Groups) Filter(flagsRe *regexp.Regexp) *Groups

Filter makes a copy of groups filtered by flagsRe

func (*Groups) Include

func (gs *Groups) Include(groupsString string) *Groups

Include makes a copy of groups only including the ones in the filter string

func (*Groups) NewGroup

func (gs *Groups) NewGroup(name, help string) *Group

NewGroup to create Group

Jump to

Keyboard shortcuts

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