types

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedTypeConversion = errors.New("unsupported type conversion")
	ErrCommandNotFound           = errors.New("command not found")
	ErrFlagNotFound              = errors.New("flag not found")
	ErrPosixIncompatible         = errors.New("posix incompatible")
	ErrValidationFailed          = errors.New("validation failed")
	ErrBindNilPointer            = errors.New("can't bind flag to nil")
	ErrVariableNotAPointer       = errors.New("variable is not a pointer")
)

Functions

This section is empty.

Types

type KeyValue

type KeyValue[K, V any] struct {
	Key   K
	Value V
}

KeyValue denotes Key Value pairs

type Kind

type Kind string

Kind is used to define the kind of entity a struct tag represents

const (
	KindFlag    Kind = "flag"
	KindCommand Kind = "command"
	KindEmpty   Kind = ""
)

type ListDelimiterFunc

type ListDelimiterFunc func(matchOn rune) bool

ListDelimiterFunc signature to match when supplying a user-defined function to check for the runes which form list delimiters. Defaults to ',' || r == '|' || r == ' '.

type OptionType

type OptionType int

OptionType used to define Flag types (such as Standalone, Single, Chained)

const (
	Empty      OptionType = iota // Empty denotes a Flag which is not set
	Single     OptionType = 1    // Single denotes a Flag accepting a string value
	Chained    OptionType = 2    // Chained denotes a Flag accepting a string value which should be evaluated as a list (split on ' ', '|' and ',')
	Standalone OptionType = 3    // Standalone denotes a boolean Flag (does not accept a value)
	File       OptionType = 4    // File denotes a Flag which is evaluated as a path (the content of the file is treated as the value)
)

func (OptionType) String added in v1.9.5

func (o OptionType) String() string

String returns the string representation of an OptionType

type PatternValue

type PatternValue struct {
	Pattern     string
	Description string
	Compiled    *regexp.Regexp
}

PatternValue is used to define an acceptable value for a Flag. The 'pattern' argument is compiled to a regular expression and the description argument is used to provide a human-readable description of the pattern.

func (*PatternValue) Describe

func (r *PatternValue) Describe() string

Describe a PatternValue (regular expression with a human-readable explanation of the pattern)

type Secure

type Secure struct {
	IsSecure bool
	Prompt   string
}

Secure set to Secure to true to solicit non-echoed user input from stdin. If Prompt is empty a "password :" prompt will be displayed. Set to the desired value to override.

type TagConfig

type TagConfig struct {
	Kind           Kind
	Name           string
	Short          string
	TypeOf         OptionType
	Description    string
	Default        string
	Required       bool
	Secure         Secure
	Path           string
	AcceptedValues []PatternValue
	DependsOn      map[string][]string
	Capacity       int
	Position       *int
}

TagConfig is used to store struct tag information about a flag or command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳