core

package
v0.0.31 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseFlag

type BaseFlag struct {
	Name             string                 // Long name (e.g. "verbose").
	Short            string                 // Short alias (single letter, e.g. "v").
	Usage            string                 // Brief description shown in help.
	Value            Value                  // Underlying value handler (scalar, slice, or dynamic).
	Hidden           bool                   // If true, omit from help.
	DisableEnv       bool                   // If true, disallow ENV lookup.
	HideEnv          bool                   // If true, hide ENV key from help.
	EnvKey           string                 // Custom environment variable (overrides derived key).
	Deprecated       string                 // If non‐empty, show deprecation notice.
	Required         bool                   // Mark flag as required.
	HideRequired     bool                   // Hide “(Required)” in help.
	Placeholder      string                 // Placeholder for the value (e.g. "FILE").
	Allowed          []string               // Allowed string values (help only).
	MutualGroup      *MutualExlusiveGroup   // Mutual exclusion group membership.
	RequiredTogether *RequiredTogetherGroup // Mutual exclusion group membership.
}

BaseFlag holds metadata for a single flag.

type DynamicItemValues

type DynamicItemValues interface {
	ValuesAny() map[string]any
}

DynamicItemValues exposes all parsed dynamic entries.

type DynamicValue

type DynamicValue interface {
	Set(id, val string) error
	FieldName() string
	GetAny(id string) (any, bool)
}

DynamicValue accepts keyed values (e.g. --http.alpha.port).

type GroupItem added in v0.0.19

type GroupItem struct {
	Value DynamicValue
	Flag  *BaseFlag
}

GroupItem holds a single flag and its value for a dynamic group.

type Incrementable

type Incrementable interface {
	Value
	Increment() error
}

Incrementable allows repeated use to increment a counter flag.

type MutualExlusiveGroup added in v0.0.31

type MutualExlusiveGroup struct {
	Name  string      // Identifier for this group.
	Flags []*BaseFlag // Member flags.
	// contains filtered or unexported fields
}

MutualExlusiveGroup enforces exclusivity among a set of flags. Only one flag in the group may be set.

func (*MutualExlusiveGroup) Hidden added in v0.0.31

Hidden marks the group as omitted from help.

func (*MutualExlusiveGroup) IsHidden added in v0.0.31

func (g *MutualExlusiveGroup) IsHidden() bool

IsHidden reports whether the group is hidden.

func (*MutualExlusiveGroup) IsRequired added in v0.0.31

func (g *MutualExlusiveGroup) IsRequired() bool

IsRequired reports whether the group is required.

func (*MutualExlusiveGroup) Required added in v0.0.31

Required enforces that one member must be set.

func (*MutualExlusiveGroup) Title added in v0.0.31

Title sets a custom help heading.

func (*MutualExlusiveGroup) TitleText added in v0.0.31

func (g *MutualExlusiveGroup) TitleText() string

TitleText returns the custom heading, if any.

type Registry

type Registry interface {
	RegisterFlag(name string, bf *BaseFlag)
	GetMutualGroup(name string) *MutualExlusiveGroup
	MutualGroups() []*MutualExlusiveGroup
	DefaultDelimiter() string
	GetRequireTogetherGroup(name string) *RequiredTogetherGroup
}

Registry manages static flags, dynamic groups, and defaults.

type RequiredTogetherGroup added in v0.0.31

type RequiredTogetherGroup struct {
	Name  string      // Identifier for this group.
	Flags []*BaseFlag // Member flags.
	// contains filtered or unexported fields
}

RequiredTogetherGroup enforces that all member flags must be set if any is set.

func (*RequiredTogetherGroup) Hidden added in v0.0.31

Hidden marks the group as omitted from help.

func (*RequiredTogetherGroup) IsHidden added in v0.0.31

func (g *RequiredTogetherGroup) IsHidden() bool

IsHidden reports whether the group is hidden.

func (*RequiredTogetherGroup) IsRequired added in v0.0.31

func (g *RequiredTogetherGroup) IsRequired() bool

IsRequired reports whether the group is required.

func (*RequiredTogetherGroup) Required added in v0.0.31

Required enforces that at least one of the group flags must be set.

func (*RequiredTogetherGroup) Title added in v0.0.31

Title sets a custom help heading.

func (*RequiredTogetherGroup) TitleText added in v0.0.31

func (g *RequiredTogetherGroup) TitleText() string

TitleText returns the custom heading, if any.

type SliceMarker

type SliceMarker interface {
	IsSlice()
}

SliceMarker tags slice-type flags (no methods).

type StrictBool

type StrictBool interface {
	IsStrictBool() bool
}

StrictBool supports --flag / --no-flag syntax.

type Value

type Value interface {
	Set(string) error // parse from string
	Get() any         // retrieve stored value
	Changed() bool    // was flag explicitly set?
	Default() string  // default value as string
}

Value parses and holds a single CLI value.

Jump to

Keyboard shortcuts

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