stdflags

package
v0.0.0-...-3db709f Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Environment variable for -config
	EnvConfig = "CONFIG"
)
View Source
const (
	// Flag name for the config filepath
	FlagConfig = "config"
)
View Source
const (
	// Usage text for -config
	FlagUsageConfig = "Configuration file location"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFlags

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

ConfigFlags is a data storage for flag.FlagSet parsing results.

func NewConfigFlags

func NewConfigFlags(fs *flag.FlagSet) *ConfigFlags

NewConfigFlags returns a ConfigFlags instance with the given flagset primed for populating its internal state.

func NewEnvConfigFlags

func NewEnvConfigFlags(fs *flag.FlagSet, prefix string) *ConfigFlags

NewEnvConfigFlags returns a ConfigFlags instance with the given flagset primed for populating its internal state. The flags usage description will include mentions of environment variables. If this is not desired, use NewConfigFlags.

The optional prefix is used as-is to create the lookup key for ConfigFlags.ParseFunc.

func (*ConfigFlags) Config

func (f *ConfigFlags) Config() *config.Config

Config returns the parsed config.

func (*ConfigFlags) ParseEnv

func (f *ConfigFlags) ParseEnv() error

ParseEnv calls ConfigFlags.ParseFunc with os.Getenv.

func (*ConfigFlags) ParseFunc

func (f *ConfigFlags) ParseFunc(get func(string) string) error

ParseFunc uses the provided function to retrieve values for the previously provisioned flagset. Values are only forwarded if they are not empty. Returned errors originate from the flag parsing logic.

Jump to

Keyboard shortcuts

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