flagutil

package module
v1.0.5-0...-01249c0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2019 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FlagSetName     = os.Args[0]
	CommandLineArgs = os.Args[1:]
	GoFlagSet       = flag.CommandLine
	PFlagSet        = pflag.CommandLine
)

Functions

This section is empty.

Types

type FlagsGroup

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

FlagsGroup is a collection of FlagSets (from either the standard library or github.com/spf13/pflag) that may be merged and kept in sync as needed.

func NewFlagsGroup

func NewFlagsGroup() *FlagsGroup

NewFlagsGroup creates a new FlagsGroup that includes the default FlagSet from both the standard flag library and github.com/spf13/pflag.

Note that all flags defined by the standard flag library are marked as Hidden in this FlagsGroup's base FlagSet (but they should still function properly). See pflag.MarkHidden for more info.

func (*FlagsGroup) AddFlagSet

func (g *FlagsGroup) AddFlagSet(o *pflag.FlagSet)

AddFlagSet adds a new pflag.FlagSet to this FlagsGroup by first adding the new FlagSet to the FlagsGroup base and then adding the FlagsGroup base to the new FlagSet. See pflag.AddFlagSet for details about flag conflicts.

func (*FlagsGroup) AddGoFlagSet

func (g *FlagsGroup) AddGoFlagSet(o *flag.FlagSet)

AddGoFlagSet adds a new flag.FlagSet (from the standard library) to this FlagsGroup. Unlike the default FlagSet, these flags are not marked as Hidden in the FlagsGroup's base FlagSet.

func (*FlagsGroup) DumpTo

func (g *FlagsGroup) DumpTo(w io.Writer)

func (*FlagsGroup) Parse

func (g *FlagsGroup) Parse() error

Parse is a convenience wrapper around ParseArgs(os.Args[1:])

func (*FlagsGroup) ParseArgs

func (g *FlagsGroup) ParseArgs(args []string) error

ParseArgs calls Parse on the base FlagSet with the given args. It then merges the newly set flag values into each of the FlagsGroup's other FlagSets.

func (*FlagsGroup) Set

func (g *FlagsGroup) Set(name, val string) error

Set is used to set flag 'name' to 'val' in all included FlagSets. If the value of 'val' cannot be applied to this flag, an error is returned.

func (*FlagsGroup) SetPrimary

func (g *FlagsGroup) SetPrimary(p *pflag.FlagSet)

SetPrimary sets the primary FlagSet to be p instead of the default created by NewFlagsGroup.

func (*FlagsGroup) SetUnless

func (g *FlagsGroup) SetUnless(name, value string) (bool, error)

func (*FlagsGroup) ValueIsSet

func (g *FlagsGroup) ValueIsSet(name string) (string, bool)

ValueIsSet returns the value of the flag 'name' and a boolean indicating whether the value was modified by the parsed command line arguments.

func (*FlagsGroup) VisitAll

func (g *FlagsGroup) VisitAll(vf func(*pflag.Flag))

VisitAll exposes the method of the same name on the FlagsGroup base FlagSet.

Jump to

Keyboard shortcuts

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