envflag: github.com/ianschenck/envflag Index | Files

package envflag

import "github.com/ianschenck/envflag"

Package envflag adds environment variable flags to the flag package.

Usage:

Define flags using envflag.String(), Bool(), Int(), etc. This package works nearly the same as the stdlib flag package. Parsing the Environment flags is done by calling envflag.Parse()

It will *not* attempt to parse any normally-defined command-line flags. Command-line flags are explicitly left alone and separate.

Index

Package Files

envflag.go

Variables

var EnvironmentFlags = flag.NewFlagSet("environment", flag.ExitOnError)

EnvironmentFlags is the default set of environment flags, parsed from os.Environ(). The top-level functions such as BoolVar, Arg, and on are wrappers for the methods of EnvironmentFlags.

func Bool Uses

func Bool(name string, value bool, usage string) *bool

Bool defines a bool flag with specified name, default value, and usage string. The return value is the address of a bool variable that stores the value of the flag.

func BoolVar Uses

func BoolVar(p *bool, name string, value bool, usage string)

BoolVar defines a bool flag with specified name, default value, and usage string. The argument p points to a bool variable in which to store the value of the flag.

func Duration Uses

func Duration(name string, value time.Duration, usage string) *time.Duration

Duration defines a time.Duration flag with specified name, default value, and usage string. The return value is the address of a time.Duration variable that stores the value of the flag.

func DurationVar Uses

func DurationVar(p *time.Duration, name string, value time.Duration, usage string)

DurationVar defines a time.Duration flag with specified name, default value, and usage string. The argument p points to a time.Duration variable in which to store the value of the flag.

func Float64 Uses

func Float64(name string, value float64, usage string) *float64

Float64 defines a float64 flag with specified name, default value, and usage string. The return value is the address of a float64 variable that stores the value of the flag.

func Float64Var Uses

func Float64Var(p *float64, name string, value float64, usage string)

Float64Var defines a float64 flag with specified name, default value, and usage string. The argument p points to a float64 variable in which to store the value of the flag.

func Int Uses

func Int(name string, value int, usage string) *int

Int defines an int flag with specified name, default value, and usage string. The return value is the address of an int variable that stores the value of the flag.

func Int64 Uses

func Int64(name string, value int64, usage string) *int64

Int64 defines an int64 flag with specified name, default value, and usage string. The return value is the address of an int64 variable that stores the value of the flag.

func Int64Var Uses

func Int64Var(p *int64, name string, value int64, usage string)

Int64Var defines an int64 flag with specified name, default value, and usage string. The argument p points to an int64 variable in which to store the value of the flag.

func IntVar Uses

func IntVar(p *int, name string, value int, usage string)

IntVar defines an int flag with specified name, default value, and usage string. The argument p points to an int variable in which to store the value of the flag.

func Lookup Uses

func Lookup(name string) *flag.Flag

Lookup returns the Flag structure of the named environment flag, returning nil if none exists.

func Parse Uses

func Parse()

Parse parses the environment flags from os.Environ. Must be called after all flags are defined and before flags are accessed by the program.

func Parsed Uses

func Parsed() bool

Parsed returns true if the environment flags have been parsed.

func PrintDefaults Uses

func PrintDefaults()

PrintDefaults prints to standard error the default values of all defined environment flags.

func Set Uses

func Set(name, value string) error

Set sets the value of the named environment flag.

func String Uses

func String(name string, value string, usage string) *string

String defines a string flag with specified name, default value, and usage string. The return value is the address of a string variable that stores the value of the flag.

func StringVar Uses

func StringVar(p *string, name string, value string, usage string)

StringVar defines a string flag with specified name, default value, and usage string. The argument p points to a string variable in which to store the value of the flag.

func Uint Uses

func Uint(name string, value uint, usage string) *uint

Uint defines a uint flag with specified name, default value, and usage string. The return value is the address of a uint variable that stores the value of the flag.

func Uint64 Uses

func Uint64(name string, value uint64, usage string) *uint64

Uint64 defines a uint64 flag with specified name, default value, and usage string. The return value is the address of a uint64 variable that stores the value of the flag.

func Uint64Var Uses

func Uint64Var(p *uint64, name string, value uint64, usage string)

Uint64Var defines a uint64 flag with specified name, default value, and usage string. The argument p points to a uint64 variable in which to store the value of the flag.

func UintVar Uses

func UintVar(p *uint, name string, value uint, usage string)

UintVar defines a uint flag with specified name, default value, and usage string. The argument p points to a uint variable in which to store the value of the flag.

func Visit Uses

func Visit(fn func(*flag.Flag))

Visit visits the environment flags in lexicographical order, calling fn for each. It visits only those flags that have been set.

func VisitAll Uses

func VisitAll(fn func(*flag.Flag))

VisitAll visits the environment flags in lexicographical order, calling fn for each. It visits all flags, even those not set.

Package envflag imports 5 packages (graph) and is imported by 46 packages. Updated 2016-09-02. Refresh now. Tools for package owners.