flags

package
v1.14.5 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MPL-2.0 Imports: 7 Imported by: 1 module, 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

Overview

Package flags provides custom pflag.Value implementations for common use cases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Semver

func Semver(defaultValue string, validators ...SemverValidateFunc) pflag.Value

Semver returns a pflag.Value that parses and stores a semantic version.

Parsing is performed using semver.ParseTolerant. After parsing, any provided SemverValidateFunc validators are applied in order and may reject the version.

The returned value is initialized with defaultValue, which is used until Set is called successfully.

func StringChoice

func StringChoice(defaultValue string, otherChoices ...string) pflag.Value

StringChoice returns a [choiceValue] that validates the value against a set of choices. Only the last value will be used if multiple values are set.

Types

type PflagExtended

type PflagExtended[T any] interface {
	pflag.Value

	Value() T
	Options() []string
}

PflagExtended extends pflag.Value with additional methods for retrieving the value as type T and getting valid string values.

func ProtoEnum

func ProtoEnum[T comparableStringer](defaultValue T, values map[string]int32, names map[int32]string) PflagExtended[T]

ProtoEnum returns a [protoEnumValue] that validates the value is correct. Only the last value will be used if multiple values are set.

type SemverValidateFunc

type SemverValidateFunc func(v semver.Version) error

SemverValidateFunc allows setting restrictions on the version.

Jump to

Keyboard shortcuts

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