flag

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 2 Imported by: 8 modules, 7 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 NewValidationError

func NewValidationError(flag string, reason error) error

NewValidationError provides a convenient helper function to create flag validation errors usable by run.Config implementations.

Types

type Set added in v0.2.0

type Set struct {
	*pflag.FlagSet
	Name string
}

Set holds a pflag.FlagSet as well as an exported Name variable for allowing improved help usage information.

func NewSet added in v0.2.0

func NewSet(name string) *Set

NewSet returns a new FlagSet for usage in Config objects.

func (*Set) SensitiveStringVar added in v0.2.0

func (s *Set) SensitiveStringVar(p *string, name, value, usage string)

func (*Set) SensitiveStringVarP added in v0.2.0

func (s *Set) SensitiveStringVarP(p *string, name, shorthand, value, usage string)

type ValidationError

type ValidationError string

ValidationError provides the ability to create constant errors for run.Group validation errors, e.g. incorrect flag values.

const (
	// FlagErr can be used as formatting string for flag related validation
	// errors where the first variable lists the flag name and the second
	// variable is the actual error.
	FlagErr = "--%s error: %w"

	// ErrRequired is returned when required config options are not provided.
	ErrRequired ValidationError = "required"

	// ErrInvalidPath is returned when a path config option is invalid.
	ErrInvalidPath ValidationError = "invalid path"

	// ErrInvalidVal is returned when the value passed into a flag argument is invalid.
	ErrInvalidVal ValidationError = "invalid value"
)

func (ValidationError) Error

func (v ValidationError) Error() string

Error implements the built-in error interface.

Jump to

Keyboard shortcuts

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