flags

package
v1.13.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

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