flag

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flag

type Flag struct {
	// Alias is an alternative name for a flag, usually shorter :)
	Alias string

	// ConfigPath is the path from the config to the value the flag updates
	ConfigPath string

	// DefaultValues will be shoved into Value if the app builder specifies it.
	// For scalar values, the last DefaultValues wins
	DefaultValues []string

	// Envvars holds a list of environment variables to update this flag. Only the first one that exists will be used.
	EnvVars []string

	// EmptyConstructor tells flag how to make a value
	EmptyValueConstructor value.EmptyConstructor

	// HelpShort is a message for the user on how to use this flag
	HelpShort HelpShort

	// Required means the user MUST fill this flag
	Required bool

	// IsCommandFlag is set when parsing. Set to true if the flag was attached to a command (as opposed to being inherited from a section)
	IsCommandFlag bool

	// SetBy might be set when parsing. Possible values: appdefault, config, passedflag
	SetBy string

	// TypeDescription is set when parsing. Describes the type: int, string, ...
	TypeDescription string

	// TypeInfo is set when parsing. Describes the "shape" of the type
	TypeInfo value.TypeInfo

	// Value might be set when parsing. The interface returned by updating a flag
	Value value.Value
}

func New added in v0.0.2

func New(helpShort HelpShort, empty value.EmptyConstructor, opts ...FlagOpt) Flag

New creates a Flag with options!

type FlagMap

type FlagMap = map[Name]Flag

FlagMap holds flags - used by Commands and Sections

type FlagOpt

type FlagOpt = func(*Flag)

FlagOpt customizes a Flag on creation

func Alias added in v0.0.3

func Alias(alias string) FlagOpt

Alias is an alternative name for a flag, usually shorter :)

func ConfigPath

func ConfigPath(path string) FlagOpt

ConfigPath adds a configpath to a flag

func Default

func Default(values ...string) FlagOpt

Default adds default values to a flag. The flag will be updated with each of the values when Resolve is called. Panics when multiple values are passed and the flags is scalar

func EnvVars added in v0.0.2

func EnvVars(name ...string) FlagOpt

EnvVars adds a list of environmental variables to search through to update this flag. The first one that exists will be used to update the flag. Further existing envvars will be ignored.

func Required added in v0.0.2

func Required() FlagOpt

Required means the user MUST fill this flag

type HelpShort added in v0.0.8

type HelpShort string

HelpShort is a description of what this flag does.

type Name added in v0.0.8

type Name string

Name of a flag

type PassedFlags added in v0.0.2

type PassedFlags = map[string]interface{} // This can just stay a string for the convenience of the user.

PassedFlags holds a map of flag names to flag Values and is passed to a command's Action

Jump to

Keyboard shortcuts

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