enumflag

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package enumflag provides a pflag.Value implementation that restricts a string flag to a fixed set of allowed values, rejecting off-enum input (including the empty string) at flag-parse time rather than silently accepting it downstream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(allowed []string, target *string, caseInsensitive bool) pflag.Value

New returns a pflag.Value that writes through to target and rejects any value not in allowed. When caseInsensitive is true, comparison is case-folded but the original (caller-typed) value is stored in target so downstream normalisation (e.g. mapPRState) sees exactly what the user passed. The empty string is never a member of allowed unless explicitly listed, so "" is rejected like any other off-enum value.

Types

This section is empty.

Jump to

Keyboard shortcuts

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