Documentation
¶
Index ¶
- Variables
- func SetExitFunc(exitFunc ExitFunc)
- func SetStderrWriter(writer StderrWriter)
- func SetStdoutWriter(writer StdoutWriter)
- type BaseFlag
- type BoolFlag
- func (f *BoolFlag) Register(cmd *Cmd, opts ...RegisterOption) (*bool, error)
- func (f *BoolFlag) RegisterWithPtr(cmd *Cmd, ptr *bool, opts ...RegisterOption) error
- func (f *BoolFlag) SetCustomUsageType(customType string) *BoolFlag
- func (f *BoolFlag) SetDefault(v bool) *BoolFlag
- func (f *BoolFlag) SetExcludes(flags []string) *BoolFlag
- func (f *BoolFlag) SetFlagOnly(b bool) *BoolFlag
- func (f *BoolFlag) SetHidden(b bool) *BoolFlag
- func (f *BoolFlag) SetHiddenInShortHelp(b bool) *BoolFlag
- func (f *BoolFlag) SetOptional(b bool) *BoolFlag
- func (f *BoolFlag) SetPositionalOnly(b bool) *BoolFlag
- func (f *BoolFlag) SetRequires(flags []string) *BoolFlag
- func (f *BoolFlag) SetShort(s string) *BoolFlag
- func (f *BoolFlag) SetUsage(u string) *BoolFlag
- type BoolSliceFlag
- type Cmd
- func (c *Cmd) Configured(name string) bool
- func (c *Cmd) GenerateArgumentsSection(isLongHelp bool) string
- func (c *Cmd) GenerateCommandsSection(isLongHelp bool) string
- func (c *Cmd) GenerateDescription() string
- func (c *Cmd) GenerateDump(args []string, opts ...ParseOpt) string
- func (c *Cmd) GenerateGlobalOptionsSection(isLongHelp bool) string
- func (c *Cmd) GenerateLongArgumentsSection() string
- func (c *Cmd) GenerateLongCommandsSection() string
- func (c *Cmd) GenerateLongGlobalOptionsSection() string
- func (c *Cmd) GenerateLongSynopsis() string
- func (c *Cmd) GenerateLongUsage() string
- func (c *Cmd) GenerateShortArgumentsSection() string
- func (c *Cmd) GenerateShortCommandsSection() string
- func (c *Cmd) GenerateShortGlobalOptionsSection() string
- func (c *Cmd) GenerateShortSynopsis() string
- func (c *Cmd) GenerateShortUsage() string
- func (c *Cmd) GenerateSynopsis(isLongHelp bool) string
- func (c *Cmd) GenerateUsage(isLongHelp bool) string
- func (c *Cmd) GetUnknownArgs() []string
- func (c *Cmd) ParseOrError(args []string, opts ...ParseOpt) error
- func (c *Cmd) ParseOrExit(args []string, opts ...ParseOpt)
- func (c *Cmd) RegisterCmd(subCmd *Cmd) (*bool, error)
- func (c *Cmd) SetAutoHelpOnNoArgs(enable bool) *Cmd
- func (c *Cmd) SetCustomUsage(fn func(isLongHelp bool)) *Cmd
- func (c *Cmd) SetDescription(desc string) *Cmd
- func (c *Cmd) SetExcludeNameFromUsage(exclude bool) *Cmd
- func (c *Cmd) SetHelpEnabled(enable bool) *Cmd
- func (c *Cmd) SetParseHooks(hooks *ParseHooks) *Cmd
- func (c *Cmd) SetUsageHeaders(headers UsageHeaders) *Cmd
- type ExitFunc
- type Flag
- type Float64Flag
- func (f *Float64Flag) Register(cmd *Cmd, opts ...RegisterOption) (*float64, error)
- func (f *Float64Flag) RegisterWithPtr(cmd *Cmd, ptr *float64, opts ...RegisterOption) error
- func (f *Float64Flag) SetCustomUsageType(customType string) *Float64Flag
- func (f *Float64Flag) SetDefault(v float64) *Float64Flag
- func (f *Float64Flag) SetExcludes(flags []string) *Float64Flag
- func (f *Float64Flag) SetFlagOnly(b bool) *Float64Flag
- func (f *Float64Flag) SetHidden(b bool) *Float64Flag
- func (f *Float64Flag) SetHiddenInShortHelp(b bool) *Float64Flag
- func (f *Float64Flag) SetMax(max float64, inclusive bool) *Float64Flag
- func (f *Float64Flag) SetMin(min float64, inclusive bool) *Float64Flag
- func (f *Float64Flag) SetOptional(b bool) *Float64Flag
- func (f *Float64Flag) SetPositionalOnly(b bool) *Float64Flag
- func (f *Float64Flag) SetRequires(flags []string) *Float64Flag
- func (f *Float64Flag) SetShort(s string) *Float64Flag
- func (f *Float64Flag) SetUsage(u string) *Float64Flag
- type Float64SliceFlag
- type Int64Flag
- func (f *Int64Flag) Register(cmd *Cmd, opts ...RegisterOption) (*int64, error)
- func (f *Int64Flag) RegisterWithPtr(cmd *Cmd, ptr *int64, opts ...RegisterOption) error
- func (f *Int64Flag) SetCustomUsageType(customType string) *Int64Flag
- func (f *Int64Flag) SetDefault(v int64) *Int64Flag
- func (f *Int64Flag) SetExcludes(flags []string) *Int64Flag
- func (f *Int64Flag) SetFlagOnly(b bool) *Int64Flag
- func (f *Int64Flag) SetHidden(b bool) *Int64Flag
- func (f *Int64Flag) SetHiddenInShortHelp(b bool) *Int64Flag
- func (f *Int64Flag) SetMax(max int64, inclusive bool) *Int64Flag
- func (f *Int64Flag) SetMin(min int64, inclusive bool) *Int64Flag
- func (f *Int64Flag) SetOptional(b bool) *Int64Flag
- func (f *Int64Flag) SetPositionalOnly(b bool) *Int64Flag
- func (f *Int64Flag) SetRequires(flags []string) *Int64Flag
- func (f *Int64Flag) SetShort(s string) *Int64Flag
- func (f *Int64Flag) SetUsage(u string) *Int64Flag
- type Int64SliceFlag
- type IntFlag
- func (f *IntFlag) Register(cmd *Cmd, opts ...RegisterOption) (*int, error)
- func (f *IntFlag) RegisterWithPtr(cmd *Cmd, ptr *int, opts ...RegisterOption) error
- func (f *IntFlag) SetCustomUsageType(customType string) *IntFlag
- func (f *IntFlag) SetDefault(v int) *IntFlag
- func (f *IntFlag) SetExcludes(flags []string) *IntFlag
- func (f *IntFlag) SetFlagOnly(b bool) *IntFlag
- func (f *IntFlag) SetHidden(b bool) *IntFlag
- func (f *IntFlag) SetHiddenInShortHelp(b bool) *IntFlag
- func (f *IntFlag) SetMax(max int, inclusive bool) *IntFlag
- func (f *IntFlag) SetMin(min int, inclusive bool) *IntFlag
- func (f *IntFlag) SetOptional(b bool) *IntFlag
- func (f *IntFlag) SetPositionalOnly(b bool) *IntFlag
- func (f *IntFlag) SetRequires(flags []string) *IntFlag
- func (f *IntFlag) SetShort(s string) *IntFlag
- func (f *IntFlag) SetUsage(u string) *IntFlag
- type IntSliceFlag
- type ParseHooks
- type ParseOpt
- type ProgrammingError
- type RegisterOption
- type SliceFlag
- func (f *SliceFlag[T]) Register(cmd *Cmd, opts ...RegisterOption) (*[]T, error)
- func (f *SliceFlag[T]) RegisterWithPtr(cmd *Cmd, ptr *[]T, opts ...RegisterOption) error
- func (f *SliceFlag[T]) SetCustomUsageType(customType string) *SliceFlag[T]
- func (f *SliceFlag[T]) SetDefault(v []T) *SliceFlag[T]
- func (f *SliceFlag[T]) SetExcludes(flags []string) *SliceFlag[T]
- func (f *SliceFlag[T]) SetFlagOnly(b bool) *SliceFlag[T]
- func (f *SliceFlag[T]) SetHidden(b bool) *SliceFlag[T]
- func (f *SliceFlag[T]) SetHiddenInShortHelp(b bool) *SliceFlag[T]
- func (f *SliceFlag[T]) SetOptional(b bool) *SliceFlag[T]
- func (f *SliceFlag[T]) SetPositionalOnly(b bool) *SliceFlag[T]
- func (f *SliceFlag[T]) SetRequires(flags []string) *SliceFlag[T]
- func (f *SliceFlag[T]) SetSeparator(sep string) *SliceFlag[T]
- func (f *SliceFlag[T]) SetShort(s string) *SliceFlag[T]
- func (f *SliceFlag[T]) SetUsage(u string) *SliceFlag[T]
- func (f *SliceFlag[T]) SetVariadic(b bool) *SliceFlag[T]
- type StderrWriter
- type StdoutWriter
- type StringFlag
- func (f *StringFlag) Register(cmd *Cmd, opts ...RegisterOption) (*string, error)
- func (f *StringFlag) RegisterWithPtr(cmd *Cmd, ptr *string, opts ...RegisterOption) error
- func (f *StringFlag) SetCustomUsageType(customType string) *StringFlag
- func (f *StringFlag) SetDefault(v string) *StringFlag
- func (f *StringFlag) SetEnumConstraint(values []string) *StringFlag
- func (f *StringFlag) SetExcludes(flags []string) *StringFlag
- func (f *StringFlag) SetFlagOnly(b bool) *StringFlag
- func (f *StringFlag) SetHidden(b bool) *StringFlag
- func (f *StringFlag) SetHiddenInShortHelp(b bool) *StringFlag
- func (f *StringFlag) SetOptional(b bool) *StringFlag
- func (f *StringFlag) SetPositionalOnly(b bool) *StringFlag
- func (f *StringFlag) SetRegexConstraint(regex *regexp.Regexp) *StringFlag
- func (f *StringFlag) SetRequires(flags []string) *StringFlag
- func (f *StringFlag) SetShort(s string) *StringFlag
- func (f *StringFlag) SetUsage(u string) *StringFlag
- type StringSliceFlag
- type UsageHeaders
Constants ¶
This section is empty.
Variables ¶
var ( GreenBoldS = greenBold.SprintfFunc() CyanS = cyan.SprintfFunc() BoldS = bold.SprintfFunc() )
var DumpInvokedErr = errors.New("dump invoked")
DumpInvokedErr is returned by ParseOrError when dump is invoked (via WithDump(true)). Users can compare against this constant to detect when dump was shown instead of parsing.
var HelpInvokedErr = errors.New("help invoked")
HelpInvokedErr is returned by ParseOrError when help is invoked (via -h, --help, or auto-help). Users can compare against this constant to detect when help was shown instead of a parsing error.
Functions ¶
func SetExitFunc ¶
func SetExitFunc(exitFunc ExitFunc)
SetExitFunc allows overriding the exit function for testing
func SetStderrWriter ¶
func SetStderrWriter(writer StderrWriter)
SetStderrWriter allows overriding the stderr writer for testing or custom output
func SetStdoutWriter ¶
func SetStdoutWriter(writer StdoutWriter)
SetStdoutWriter allows overriding the stdout writer for testing or custom output
Types ¶
type BaseFlag ¶
type BaseFlag struct { Name string // Primary identifier for the flag Short string // Single character short flag (e.g., 'v' for -v) Usage string // Help text description shown in usage CustomUsageType string // Custom type string for usage display (overrides auto-detection) Optional bool // Whether the flag is optional (default: required) Hidden bool // Hide from all help output HiddenInShortHelp bool // Hide from short help (-h), show in long help (--help) PositionalOnly bool // Can only be passed positionally, not as --flag FlagOnly bool // Can only be passed as --flag, not positionally Excludes *[]string // Flags that cannot be used with this flag Requires *[]string // Flags that must be present when this flag is used BypassValidation bool // If true, this flag can bypass normal validation requirements }
type BoolFlag ¶
func (*BoolFlag) Register ¶
func (f *BoolFlag) Register(cmd *Cmd, opts ...RegisterOption) (*bool, error)
func (*BoolFlag) RegisterWithPtr ¶
func (f *BoolFlag) RegisterWithPtr(cmd *Cmd, ptr *bool, opts ...RegisterOption) error
func (*BoolFlag) SetCustomUsageType ¶
func (*BoolFlag) SetDefault ¶
func (*BoolFlag) SetExcludes ¶
func (*BoolFlag) SetFlagOnly ¶
func (*BoolFlag) SetHiddenInShortHelp ¶
func (*BoolFlag) SetOptional ¶
func (*BoolFlag) SetPositionalOnly ¶
func (*BoolFlag) SetRequires ¶
type BoolSliceFlag ¶
func NewBoolSlice ¶
func NewBoolSlice(name string) *BoolSliceFlag
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
func (*Cmd) Configured ¶
Whether a flag was explicitly configured by the user.
func (*Cmd) GenerateArgumentsSection ¶
func (*Cmd) GenerateCommandsSection ¶
func (*Cmd) GenerateDescription ¶
func (*Cmd) GenerateDump ¶ added in v0.3.0
GenerateDump creates a comprehensive dump of the command structure and parsing context
func (*Cmd) GenerateGlobalOptionsSection ¶
func (*Cmd) GenerateLongArgumentsSection ¶
func (*Cmd) GenerateLongCommandsSection ¶
func (*Cmd) GenerateLongGlobalOptionsSection ¶
func (*Cmd) GenerateLongSynopsis ¶
func (*Cmd) GenerateLongUsage ¶
func (*Cmd) GenerateShortArgumentsSection ¶
func (*Cmd) GenerateShortCommandsSection ¶
func (*Cmd) GenerateShortGlobalOptionsSection ¶
func (*Cmd) GenerateShortSynopsis ¶
func (*Cmd) GenerateShortUsage ¶
func (*Cmd) GenerateSynopsis ¶
func (*Cmd) GenerateUsage ¶
func (*Cmd) GetUnknownArgs ¶
func (*Cmd) ParseOrExit ¶
func (*Cmd) SetAutoHelpOnNoArgs ¶
func (*Cmd) SetCustomUsage ¶
func (*Cmd) SetDescription ¶
func (*Cmd) SetExcludeNameFromUsage ¶
func (*Cmd) SetHelpEnabled ¶
func (*Cmd) SetParseHooks ¶
func (c *Cmd) SetParseHooks(hooks *ParseHooks) *Cmd
func (*Cmd) SetUsageHeaders ¶
func (c *Cmd) SetUsageHeaders(headers UsageHeaders) *Cmd
type Float64Flag ¶
func NewFloat64 ¶
func NewFloat64(name string) *Float64Flag
func (*Float64Flag) Register ¶
func (f *Float64Flag) Register(cmd *Cmd, opts ...RegisterOption) (*float64, error)
func (*Float64Flag) RegisterWithPtr ¶
func (f *Float64Flag) RegisterWithPtr(cmd *Cmd, ptr *float64, opts ...RegisterOption) error
func (*Float64Flag) SetCustomUsageType ¶
func (f *Float64Flag) SetCustomUsageType(customType string) *Float64Flag
func (*Float64Flag) SetDefault ¶
func (f *Float64Flag) SetDefault(v float64) *Float64Flag
func (*Float64Flag) SetExcludes ¶
func (f *Float64Flag) SetExcludes(flags []string) *Float64Flag
func (*Float64Flag) SetFlagOnly ¶
func (f *Float64Flag) SetFlagOnly(b bool) *Float64Flag
func (*Float64Flag) SetHidden ¶
func (f *Float64Flag) SetHidden(b bool) *Float64Flag
func (*Float64Flag) SetHiddenInShortHelp ¶
func (f *Float64Flag) SetHiddenInShortHelp(b bool) *Float64Flag
func (*Float64Flag) SetMax ¶
func (f *Float64Flag) SetMax(max float64, inclusive bool) *Float64Flag
func (*Float64Flag) SetMin ¶
func (f *Float64Flag) SetMin(min float64, inclusive bool) *Float64Flag
func (*Float64Flag) SetOptional ¶
func (f *Float64Flag) SetOptional(b bool) *Float64Flag
func (*Float64Flag) SetPositionalOnly ¶
func (f *Float64Flag) SetPositionalOnly(b bool) *Float64Flag
func (*Float64Flag) SetRequires ¶
func (f *Float64Flag) SetRequires(flags []string) *Float64Flag
func (*Float64Flag) SetShort ¶
func (f *Float64Flag) SetShort(s string) *Float64Flag
func (*Float64Flag) SetUsage ¶
func (f *Float64Flag) SetUsage(u string) *Float64Flag
type Float64SliceFlag ¶
func NewFloat64Slice ¶
func NewFloat64Slice(name string) *Float64SliceFlag
type Int64Flag ¶
func (*Int64Flag) Register ¶
func (f *Int64Flag) Register(cmd *Cmd, opts ...RegisterOption) (*int64, error)
func (*Int64Flag) RegisterWithPtr ¶
func (f *Int64Flag) RegisterWithPtr(cmd *Cmd, ptr *int64, opts ...RegisterOption) error
func (*Int64Flag) SetCustomUsageType ¶
func (*Int64Flag) SetDefault ¶
func (*Int64Flag) SetExcludes ¶
func (*Int64Flag) SetFlagOnly ¶
func (*Int64Flag) SetHiddenInShortHelp ¶
func (*Int64Flag) SetOptional ¶
func (*Int64Flag) SetPositionalOnly ¶
func (*Int64Flag) SetRequires ¶
type Int64SliceFlag ¶
func NewInt64Slice ¶
func NewInt64Slice(name string) *Int64SliceFlag
type IntFlag ¶
func (*IntFlag) Register ¶
func (f *IntFlag) Register(cmd *Cmd, opts ...RegisterOption) (*int, error)
func (*IntFlag) RegisterWithPtr ¶
func (f *IntFlag) RegisterWithPtr(cmd *Cmd, ptr *int, opts ...RegisterOption) error
func (*IntFlag) SetCustomUsageType ¶
func (*IntFlag) SetDefault ¶
func (*IntFlag) SetExcludes ¶
func (*IntFlag) SetFlagOnly ¶
func (*IntFlag) SetHiddenInShortHelp ¶
func (*IntFlag) SetOptional ¶
func (*IntFlag) SetPositionalOnly ¶
func (*IntFlag) SetRequires ¶
type IntSliceFlag ¶
func NewIntSlice ¶
func NewIntSlice(name string) *IntSliceFlag
type ParseHooks ¶
type ProgrammingError ¶
type ProgrammingError struct {
// contains filtered or unexported fields
}
ProgrammingError wraps errors caused by incorrect library setup/configuration. These are bugs in the code using Ra, not user input errors.
func NewProgrammingError ¶
func NewProgrammingError(msg string) *ProgrammingError
NewProgrammingError creates a new programming error
func (*ProgrammingError) Error ¶
func (e *ProgrammingError) Error() string
type RegisterOption ¶
type RegisterOption func(*registerConfig)
func WithBypassValidation ¶
func WithBypassValidation(b bool) RegisterOption
func WithGlobal ¶
func WithGlobal(g bool) RegisterOption
type SliceFlag ¶
func (*SliceFlag[T]) Register ¶
func (f *SliceFlag[T]) Register(cmd *Cmd, opts ...RegisterOption) (*[]T, error)
func (*SliceFlag[T]) RegisterWithPtr ¶
func (f *SliceFlag[T]) RegisterWithPtr(cmd *Cmd, ptr *[]T, opts ...RegisterOption) error
func (*SliceFlag[T]) SetCustomUsageType ¶
func (*SliceFlag[T]) SetDefault ¶
func (*SliceFlag[T]) SetExcludes ¶
func (*SliceFlag[T]) SetFlagOnly ¶
func (*SliceFlag[T]) SetHiddenInShortHelp ¶
func (*SliceFlag[T]) SetOptional ¶
func (*SliceFlag[T]) SetPositionalOnly ¶
func (*SliceFlag[T]) SetRequires ¶
func (*SliceFlag[T]) SetSeparator ¶
func (*SliceFlag[T]) SetVariadic ¶
type StderrWriter ¶
StderrWriter is the interface for writing to stderr
type StdoutWriter ¶
StdoutWriter is the interface for writing to stdout
type StringFlag ¶
type StringFlag struct { Flag[string] EnumConstraint *[]string // if set, the value must be one of these RegexConstraint *regexp.Regexp // if set, the value must match this regex }
func NewString ¶
func NewString(name string) *StringFlag
func (*StringFlag) Register ¶
func (f *StringFlag) Register(cmd *Cmd, opts ...RegisterOption) (*string, error)
func (*StringFlag) RegisterWithPtr ¶
func (f *StringFlag) RegisterWithPtr(cmd *Cmd, ptr *string, opts ...RegisterOption) error
func (*StringFlag) SetCustomUsageType ¶
func (f *StringFlag) SetCustomUsageType(customType string) *StringFlag
func (*StringFlag) SetDefault ¶
func (f *StringFlag) SetDefault(v string) *StringFlag
func (*StringFlag) SetEnumConstraint ¶
func (f *StringFlag) SetEnumConstraint(values []string) *StringFlag
func (*StringFlag) SetExcludes ¶
func (f *StringFlag) SetExcludes(flags []string) *StringFlag
func (*StringFlag) SetFlagOnly ¶
func (f *StringFlag) SetFlagOnly(b bool) *StringFlag
func (*StringFlag) SetHidden ¶
func (f *StringFlag) SetHidden(b bool) *StringFlag
func (*StringFlag) SetHiddenInShortHelp ¶
func (f *StringFlag) SetHiddenInShortHelp(b bool) *StringFlag
func (*StringFlag) SetOptional ¶
func (f *StringFlag) SetOptional(b bool) *StringFlag
func (*StringFlag) SetPositionalOnly ¶
func (f *StringFlag) SetPositionalOnly(b bool) *StringFlag
func (*StringFlag) SetRegexConstraint ¶
func (f *StringFlag) SetRegexConstraint(regex *regexp.Regexp) *StringFlag
func (*StringFlag) SetRequires ¶
func (f *StringFlag) SetRequires(flags []string) *StringFlag
func (*StringFlag) SetShort ¶
func (f *StringFlag) SetShort(s string) *StringFlag
func (*StringFlag) SetUsage ¶
func (f *StringFlag) SetUsage(u string) *StringFlag
type StringSliceFlag ¶
func NewStringSlice ¶
func NewStringSlice(name string) *StringSliceFlag
type UsageHeaders ¶
func DefaultUsageHeaders ¶
func DefaultUsageHeaders() UsageHeaders