Documentation
¶
Overview ¶
Package cliflag provides self-describing CLI flag types. An EnumValue carries its own set of allowed values, so (1) the CLI validates input at parse time — an out-of-set value is rejected with a clear message instead of silently accepted — and (2) the docs generator reads the allowed set directly, rendering the real options instead of hoping the usage string mentions them. One source of truth for --help and the reference docs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnumVar ¶
EnumVar registers an enum-constrained string flag on fs. The usage should be plain prose (no value list) — the allowed values are appended for --help and surfaced separately in the docs.
func OptionsSuffix ¶
OptionsSuffix is the " (one of: …)" hint appended to an enum flag's usage so `--help` lists the allowed values inline. It is shared with the docs generator, which strips it back off (the reference renders the values in a dedicated Options column instead, so keeping it in the description too would be redundant). Empty for a non-enum.
Types ¶
type EnumValue ¶
type EnumValue struct {
// contains filtered or unexported fields
}
EnumValue is a pflag.Value backed by a fixed set of allowed strings.
func NewEnum ¶
NewEnum stores def into target and returns an EnumValue constrained to allowed. An empty def (a common "fall back to config" sentinel) is permitted and left as-is.