flags

package
v0.0.0-...-6d11654 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlagToEnv

func FlagToEnv(prefix, name string) string

FlagToEnv converts flag string to upper-case environment variable key string.

func IsPSet

func IsPSet(fs *pflag.FlagSet, name string) bool

IsPSet checks if flagset has set but with pflag

func IsSet

func IsSet(fs *flag.FlagSet, name string) bool

IsSet checks if flagset has set

func SetFlagsFromEnv

func SetFlagsFromEnv(prefix string, fs *flag.FlagSet) error

SetFlagsFromEnv parses all registered flags in the given flagset, and if they are not already set it attempts to set their values from environment variables. Environment variables take the name of the flag but are UPPERCASE, have the given prefix and any dashes are replaced by underscores - for example: some-flag => PREFIX_SOME_FLAG

func SetPflagsFromEnv

func SetPflagsFromEnv(prefix string, fs *pflag.FlagSet) error

SetPflagsFromEnv is similar to SetFlagsFromEnv. However, the accepted flagset type is pflag.FlagSet and it does not do any logging.

Types

type DeprecatedFlag

type DeprecatedFlag struct {
	Name string
}

DeprecatedFlag encapsulates a flag that may have been previously valid but is now deprecated. If a DeprecatedFlag is set, an error occurs.

func (*DeprecatedFlag) Set

func (f *DeprecatedFlag) Set(_ string) error

Set returns an error

func (*DeprecatedFlag) String

func (f *DeprecatedFlag) String() string

String ...

type IgnoredFlag

type IgnoredFlag struct {
	Name string
}

IgnoredFlag encapsulates a flag that may have been previously valid but is now ignored. If an IgnoredFlag is set, a warning is printed and operation continues.

func (*IgnoredFlag) IsBoolFlag

func (f *IgnoredFlag) IsBoolFlag() bool

IsBoolFlag is defined to allow the flag to be defined without an argument

func (*IgnoredFlag) Set

func (f *IgnoredFlag) Set(s string) error

Set is not supported anymore

func (*IgnoredFlag) String

func (f *IgnoredFlag) String() string

String ...

Jump to

Keyboard shortcuts

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