ra

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 8 Imported by: 1

README

Ra

ra-logo

Latest Release Go Reference Go Report Card

Flexible CLI argument parsing for Go. Ra lets you build sophisticated command-line tools where arguments work as both positional parameters and named flags - giving your users the flexibility to use whichever style feels natural.

Powers the argument parsing in Rad! ⚡️

Quick Start

go get github.com/amterp/ra
package main

import (
	"fmt"
	"os"
	"github.com/amterp/ra"
)

func main() {
	cmd := ra.NewCmd("myapp")

	// This arg works both positionally AND as a flag
	input, _ := ra.NewString("input").Register(cmd)
	format, _ := ra.NewString("format").SetDefault("json").Register(cmd)
	verbose, _ := ra.NewBool("verbose").SetShort("v").Register(cmd)

	cmd.ParseOrExit(os.Args[1:])

	fmt.Printf("Input: %s, Format: %s, Verbose: %t\n", *input, *format, *verbose)
}

Both of these work identically:

myapp data.txt json --verbose     # positional style
myapp --input data.txt --format json -v  # flag style  

Key Features

  • 🎭 Dual-Nature Arguments: Every argument works as both a positional parameter and a named flag
  • 🔒 Rich Constraints: Enum values, regex patterns, min/max ranges, and relational constraints (requires/excludes)
  • 🧠 Smart Parsing: Bool flag clustering (-abc), negative number handling, variadic arguments
  • 🛡️ Type Safety: Generic flag types with compile-time safety and automatic validation
  • 🌳 Subcommands: Nested commands with global flag inheritance
  • 💫 User-Friendly: Auto-help generation, colorized output, clear error messages

Why Ra?

vs cobra/pflag: While cobra and pflag are excellent for traditional flag-based CLIs, Ra's dual-nature arguments provide more flexibility. In cobra, you have to choose between positional args OR flags - Ra lets you have both.

// Cobra: Separate definitions for flags and positional args
cmd.Flags().StringVarP(&input, "input", "i", "", "input file")
cmd.Args = cobra.ExactArgs(1) // The positional arg is separate

// Ra: A single declaration enables both styles  
input, _ := ra.NewString("input").Register(cmd)
// User can use `myapp file.txt` OR `myapp --input file.txt`
Feature Ra cobra/pflag
Argument Style Dual-nature (flags & positional) Primarily flags-only
POSIX Compliance Flexible / Non-prescriptive Strict patterns
Built-in Validation Rich constraints (enum, regex, ranges) Basic type parsing
Best For User-friendly CLIs with flexible UX Traditional POSIX-style tools

Perfect for CLIs that need more flexibility than basic flag parsing but less complexity than full frameworks.

Example

package main

import (
	"fmt"
	"os"
	"github.com/amterp/ra"
)

func main() {
	cmd := ra.NewCmd("fileproc")
	cmd.SetDescription("A file processor with various output formats")

	// Required input file (positional or --input)
	input, _ := ra.NewString("input").Register(cmd)

	// Format with enum constraint and default
	format, _ := ra.NewString("format").
		SetShort("f").
		SetDefault("json").
		SetEnumConstraint([]string{"json", "xml", "yaml"}).
		Register(cmd)

	// Timeout with range constraint
	timeout, _ := ra.NewInt("timeout").
		SetDefault(30).
		SetMin(1, true).SetMax(300, true).
		Register(cmd)

	// Mutually exclusive flags
	verbose, _ := ra.NewBool("verbose").
		SetShort("v").
		SetExcludes([]string{"quiet"}).
		Register(cmd)

	quiet, _ := ra.NewBool("quiet").
		SetShort("q").
		SetExcludes([]string{"verbose"}).
		Register(cmd)

	// Variadic tags
	tags, _ := ra.NewStringSlice("tags").
		SetVariadic(true).
		SetOptional(true).
		Register(cmd)

	// Subcommand
	validateCmd := ra.NewCmd("validate")
	validateInput, _ := ra.NewString("input").Register(validateCmd)
	strict, _ := ra.NewBool("strict").Register(validateCmd)
	validateUsed, _ := cmd.RegisterCmd(validateCmd)

	// Parse
	err := cmd.ParseOrError(os.Args[1:])
	if err == ra.HelpInvokedErr {
		return // Help was shown
	} else if err != nil {
		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
		os.Exit(1)
	}

	// Handle subcommand
	if *validateUsed {
		fmt.Printf("Validating: %s (strict: %t)\n", *validateInput, *strict)
		return
	}

	// Main processing
	fmt.Printf("Processing %s -> %s format (timeout: %ds)\n",
		*input, *format, *timeout)

	if *verbose {
		fmt.Println("Verbose mode enabled")
	} else if *quiet {
		fmt.Println("Quiet mode enabled")
	}

	if len(*tags) > 0 {
		fmt.Printf("Tags: %v\n", *tags)
	}
}

Usage examples:

# All equivalent ways to call the same thing:
fileproc data.txt                           # positional
fileproc --input data.txt                   # flag style
fileproc data.txt --format xml -v          # mixed style
fileproc data.txt xml 60 --tags api,prod   # mostly positional

# Subcommand
fileproc validate config.json --strict

# Auto-generated help
fileproc --help
# Output:
# A file processor with various output formats
#
# Usage:
#   fileproc [validate] <input> [format] [timeout] [OPTIONS]
#
# Commands:
#   validate
#
# Arguments:
#       --input str         
#   -f, --format str        Default: json. Valid values: [json, xml, yaml]
#       --timeout int       Default: 30. Range: [1, 300]
#   -v, --verbose           Excludes: quiet
#   -q, --quiet             Excludes: verbose  
#       --tags [strs...]    (optional)
#   -h, --help              Print usage information

# Constraint validation errors
fileproc data.txt --format csv
# Output: Error: Invalid 'format' value: csv (valid values: json, xml, yaml)

fileproc data.txt --timeout 500  
# Output: Error: 'timeout' value 500 is > maximum 300

Documentation

Requirements

  • Go 1.24+

License

MIT License.

Contributing

See CONTRIBUTING.md for development guidelines.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GreenBoldS = greenBold.SprintfFunc()
	CyanS      = cyan.SprintfFunc()
	BoldS      = bold.SprintfFunc()
)
View Source
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.

View Source
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

type BoolFlag struct {
	Flag[bool]
}

func NewBool

func NewBool(name string) *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 (f *BoolFlag) SetCustomUsageType(customType string) *BoolFlag

func (*BoolFlag) SetDefault

func (f *BoolFlag) SetDefault(v bool) *BoolFlag

func (*BoolFlag) SetExcludes

func (f *BoolFlag) SetExcludes(flags []string) *BoolFlag

func (*BoolFlag) SetFlagOnly

func (f *BoolFlag) SetFlagOnly(b bool) *BoolFlag

func (*BoolFlag) SetHidden

func (f *BoolFlag) SetHidden(b bool) *BoolFlag

func (*BoolFlag) SetHiddenInShortHelp

func (f *BoolFlag) SetHiddenInShortHelp(b bool) *BoolFlag

func (*BoolFlag) SetOptional

func (f *BoolFlag) SetOptional(b bool) *BoolFlag

func (*BoolFlag) SetPositionalOnly

func (f *BoolFlag) SetPositionalOnly(b bool) *BoolFlag

func (*BoolFlag) SetRequires

func (f *BoolFlag) SetRequires(flags []string) *BoolFlag

func (*BoolFlag) SetShort

func (f *BoolFlag) SetShort(s string) *BoolFlag

func (*BoolFlag) SetUsage

func (f *BoolFlag) SetUsage(u string) *BoolFlag

type BoolSliceFlag

type BoolSliceFlag = SliceFlag[bool]

func NewBoolSlice

func NewBoolSlice(name string) *BoolSliceFlag

type Cmd

type Cmd struct {
	// contains filtered or unexported fields
}

func NewCmd

func NewCmd(name string) *Cmd

func (*Cmd) Configured

func (c *Cmd) Configured(name string) bool

Whether a flag was explicitly configured by the user.

func (*Cmd) GenerateArgumentsSection

func (c *Cmd) GenerateArgumentsSection(isLongHelp bool) string

func (*Cmd) GenerateCommandsSection

func (c *Cmd) GenerateCommandsSection(isLongHelp bool) string

func (*Cmd) GenerateDescription

func (c *Cmd) GenerateDescription() string

func (*Cmd) GenerateDump added in v0.3.0

func (c *Cmd) GenerateDump(args []string, opts ...ParseOpt) string

GenerateDump creates a comprehensive dump of the command structure and parsing context

func (*Cmd) GenerateGlobalOptionsSection

func (c *Cmd) GenerateGlobalOptionsSection(isLongHelp bool) string

func (*Cmd) GenerateLongArgumentsSection

func (c *Cmd) GenerateLongArgumentsSection() string

func (*Cmd) GenerateLongCommandsSection

func (c *Cmd) GenerateLongCommandsSection() string

func (*Cmd) GenerateLongGlobalOptionsSection

func (c *Cmd) GenerateLongGlobalOptionsSection() string

func (*Cmd) GenerateLongSynopsis

func (c *Cmd) GenerateLongSynopsis() string

func (*Cmd) GenerateLongUsage

func (c *Cmd) GenerateLongUsage() string

func (*Cmd) GenerateShortArgumentsSection

func (c *Cmd) GenerateShortArgumentsSection() string

func (*Cmd) GenerateShortCommandsSection

func (c *Cmd) GenerateShortCommandsSection() string

func (*Cmd) GenerateShortGlobalOptionsSection

func (c *Cmd) GenerateShortGlobalOptionsSection() string

func (*Cmd) GenerateShortSynopsis

func (c *Cmd) GenerateShortSynopsis() string

func (*Cmd) GenerateShortUsage

func (c *Cmd) GenerateShortUsage() string

func (*Cmd) GenerateSynopsis

func (c *Cmd) GenerateSynopsis(isLongHelp bool) string

func (*Cmd) GenerateUsage

func (c *Cmd) GenerateUsage(isLongHelp bool) string

func (*Cmd) GetUnknownArgs

func (c *Cmd) GetUnknownArgs() []string

func (*Cmd) ParseOrError

func (c *Cmd) ParseOrError(args []string, opts ...ParseOpt) error

func (*Cmd) ParseOrExit

func (c *Cmd) ParseOrExit(args []string, opts ...ParseOpt)

func (*Cmd) RegisterCmd

func (c *Cmd) RegisterCmd(subCmd *Cmd) (*bool, error)

func (*Cmd) SetAutoHelpOnNoArgs

func (c *Cmd) SetAutoHelpOnNoArgs(enable bool) *Cmd

func (*Cmd) SetCustomUsage

func (c *Cmd) SetCustomUsage(fn func(isLongHelp bool)) *Cmd

func (*Cmd) SetDescription

func (c *Cmd) SetDescription(desc string) *Cmd

func (*Cmd) SetExcludeNameFromUsage

func (c *Cmd) SetExcludeNameFromUsage(exclude bool) *Cmd

func (*Cmd) SetHelpEnabled

func (c *Cmd) SetHelpEnabled(enable bool) *Cmd

func (*Cmd) SetParseHooks

func (c *Cmd) SetParseHooks(hooks *ParseHooks) *Cmd

func (*Cmd) SetUsageHeaders

func (c *Cmd) SetUsageHeaders(headers UsageHeaders) *Cmd

type ExitFunc

type ExitFunc func(int)

ExitFunc is the interface for exiting the program

type Flag

type Flag[T any] struct {
	BaseFlag
	Default *T // Default value when flag is not specified
	Value   *T // Pointer to the parsed value (set during parsing)
}

type Float64Flag

type Float64Flag struct {
	Flag[float64]
	// contains filtered or unexported fields
}

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

type Float64SliceFlag = SliceFlag[float64]

func NewFloat64Slice

func NewFloat64Slice(name string) *Float64SliceFlag

type Int64Flag

type Int64Flag struct {
	Flag[int64]
	// contains filtered or unexported fields
}

func NewInt64

func NewInt64(name string) *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 (f *Int64Flag) SetCustomUsageType(customType string) *Int64Flag

func (*Int64Flag) SetDefault

func (f *Int64Flag) SetDefault(v int64) *Int64Flag

func (*Int64Flag) SetExcludes

func (f *Int64Flag) SetExcludes(flags []string) *Int64Flag

func (*Int64Flag) SetFlagOnly

func (f *Int64Flag) SetFlagOnly(b bool) *Int64Flag

func (*Int64Flag) SetHidden

func (f *Int64Flag) SetHidden(b bool) *Int64Flag

func (*Int64Flag) SetHiddenInShortHelp

func (f *Int64Flag) SetHiddenInShortHelp(b bool) *Int64Flag

func (*Int64Flag) SetMax

func (f *Int64Flag) SetMax(max int64, inclusive bool) *Int64Flag

func (*Int64Flag) SetMin

func (f *Int64Flag) SetMin(min int64, inclusive bool) *Int64Flag

func (*Int64Flag) SetOptional

func (f *Int64Flag) SetOptional(b bool) *Int64Flag

func (*Int64Flag) SetPositionalOnly

func (f *Int64Flag) SetPositionalOnly(b bool) *Int64Flag

func (*Int64Flag) SetRequires

func (f *Int64Flag) SetRequires(flags []string) *Int64Flag

func (*Int64Flag) SetShort

func (f *Int64Flag) SetShort(s string) *Int64Flag

func (*Int64Flag) SetUsage

func (f *Int64Flag) SetUsage(u string) *Int64Flag

type Int64SliceFlag

type Int64SliceFlag = SliceFlag[int64]

func NewInt64Slice

func NewInt64Slice(name string) *Int64SliceFlag

type IntFlag

type IntFlag struct {
	Flag[int]
	// contains filtered or unexported fields
}

func NewInt

func NewInt(name string) *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 (f *IntFlag) SetCustomUsageType(customType string) *IntFlag

func (*IntFlag) SetDefault

func (f *IntFlag) SetDefault(v int) *IntFlag

func (*IntFlag) SetExcludes

func (f *IntFlag) SetExcludes(flags []string) *IntFlag

func (*IntFlag) SetFlagOnly

func (f *IntFlag) SetFlagOnly(b bool) *IntFlag

func (*IntFlag) SetHidden

func (f *IntFlag) SetHidden(b bool) *IntFlag

func (*IntFlag) SetHiddenInShortHelp

func (f *IntFlag) SetHiddenInShortHelp(b bool) *IntFlag

func (*IntFlag) SetMax

func (f *IntFlag) SetMax(max int, inclusive bool) *IntFlag

func (*IntFlag) SetMin

func (f *IntFlag) SetMin(min int, inclusive bool) *IntFlag

func (*IntFlag) SetOptional

func (f *IntFlag) SetOptional(b bool) *IntFlag

func (*IntFlag) SetPositionalOnly

func (f *IntFlag) SetPositionalOnly(b bool) *IntFlag

func (*IntFlag) SetRequires

func (f *IntFlag) SetRequires(flags []string) *IntFlag

func (*IntFlag) SetShort

func (f *IntFlag) SetShort(s string) *IntFlag

func (*IntFlag) SetUsage

func (f *IntFlag) SetUsage(u string) *IntFlag

type IntSliceFlag

type IntSliceFlag = SliceFlag[int]

func NewIntSlice

func NewIntSlice(name string) *IntSliceFlag

type ParseHooks

type ParseHooks struct {
	PostParse func(cmd *Cmd, err error) // Called after parsing, before any output
}

type ParseOpt

type ParseOpt func(*parseCfg)

func WithDump added in v0.3.0

func WithDump(dump bool) ParseOpt

func WithIgnoreUnknown

func WithIgnoreUnknown(ignore bool) ParseOpt

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

type SliceFlag[T any] struct {
	BaseFlag
	Separator *string
	Variadic  bool
	Default   *[]T
	Value     *[]T
}

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 (f *SliceFlag[T]) SetCustomUsageType(customType string) *SliceFlag[T]

func (*SliceFlag[T]) SetDefault

func (f *SliceFlag[T]) SetDefault(v []T) *SliceFlag[T]

func (*SliceFlag[T]) SetExcludes

func (f *SliceFlag[T]) SetExcludes(flags []string) *SliceFlag[T]

func (*SliceFlag[T]) SetFlagOnly

func (f *SliceFlag[T]) SetFlagOnly(b bool) *SliceFlag[T]

func (*SliceFlag[T]) SetHidden

func (f *SliceFlag[T]) SetHidden(b bool) *SliceFlag[T]

func (*SliceFlag[T]) SetHiddenInShortHelp

func (f *SliceFlag[T]) SetHiddenInShortHelp(b bool) *SliceFlag[T]

func (*SliceFlag[T]) SetOptional

func (f *SliceFlag[T]) SetOptional(b bool) *SliceFlag[T]

func (*SliceFlag[T]) SetPositionalOnly

func (f *SliceFlag[T]) SetPositionalOnly(b bool) *SliceFlag[T]

func (*SliceFlag[T]) SetRequires

func (f *SliceFlag[T]) SetRequires(flags []string) *SliceFlag[T]

func (*SliceFlag[T]) SetSeparator

func (f *SliceFlag[T]) SetSeparator(sep string) *SliceFlag[T]

func (*SliceFlag[T]) SetShort

func (f *SliceFlag[T]) SetShort(s string) *SliceFlag[T]

func (*SliceFlag[T]) SetUsage

func (f *SliceFlag[T]) SetUsage(u string) *SliceFlag[T]

func (*SliceFlag[T]) SetVariadic

func (f *SliceFlag[T]) SetVariadic(b bool) *SliceFlag[T]

type StderrWriter

type StderrWriter interface {
	Write([]byte) (int, error)
}

StderrWriter is the interface for writing to stderr

type StdoutWriter

type StdoutWriter interface {
	Write([]byte) (int, error)
}

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

type StringSliceFlag = SliceFlag[string]

func NewStringSlice

func NewStringSlice(name string) *StringSliceFlag

type UsageHeaders

type UsageHeaders struct {
	Usage         string
	Commands      string
	Arguments     string
	GlobalOptions string
}

func DefaultUsageHeaders

func DefaultUsageHeaders() UsageHeaders

Jump to

Keyboard shortcuts

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