flags

package
v3.8.0-alpha.0+incompa... Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2017 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(args map[string][]string, flags *pflag.FlagSet) []error

Apply stores the provided arguments onto a flag set, reporting any errors encountered during the process.

func AsArgs

func AsArgs(fn, defaultFn func(*pflag.FlagSet)) []string

func Resolve

func Resolve(args map[string][]string, fn func(*pflag.FlagSet)) []error

Types

type ComponentFlag

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

ComponentFlag represents a set of enabled components used in a command line.

func NewComponentFlag

func NewComponentFlag(mappings map[string][]string, allowed ...string) *ComponentFlag

NewComponentFlag returns a flag that represents the allowed components and can be bound to command line flags.

func (*ComponentFlag) Allowed

func (f *ComponentFlag) Allowed() sets.String

Allowed returns a copy of the allowed list of components.

func (*ComponentFlag) Bind

func (f *ComponentFlag) Bind(flags *pflag.FlagSet, flagFormat, messagePrefix string)

Bind registers the necessary flags with a flag set.

func (*ComponentFlag) Calculated

func (f *ComponentFlag) Calculated() sets.String

Calculated returns the effective enabled list.

func (*ComponentFlag) DefaultDisable

func (f *ComponentFlag) DefaultDisable(components ...string) *ComponentFlag

DefaultDisable resets the default enabled set to all allowed components except the provided.

func (*ComponentFlag) DefaultEnable

func (f *ComponentFlag) DefaultEnable(components ...string) *ComponentFlag

DefaultEnable resets the enabled components to only those provided that are also in the allowed list.

func (*ComponentFlag) Disable

func (f *ComponentFlag) Disable(components ...string)

Disable marks the provided components as disabled.

func (*ComponentFlag) Enabled

func (f *ComponentFlag) Enabled(name string) bool

Enabled returns true if the component is enabled.

func (*ComponentFlag) Expand

func (f *ComponentFlag) Expand(value string) sets.String

Expand turns a string into a fully expanded set of components, resolving any mappings.

func (*ComponentFlag) Mappings

func (f *ComponentFlag) Mappings() map[string][]string

Mappings returns a copy of the mapping list for short names.

func (*ComponentFlag) Validate

func (f *ComponentFlag) Validate() (sets.String, error)

Validate returns a copy of the set of enabled components, or an error if there are conflicts.

Jump to

Keyboard shortcuts

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