args

package
v0.12.19 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

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

Argument holds parsing metadata and the optional user supplied value.

func (*Argument) Get

func (arg *Argument) Get() string

Get returns the current value (default or user supplied).

func (*Argument) Is_Specified

func (arg *Argument) Is_Specified() bool

Is_Specified reports whether a value has been explicitly provided.

type Parser

type Parser struct {

	// Args stores registered arguments and values discovered during parsing.
	Args map[string]*Argument
	// contains filtered or unexported fields
}

Parser parses alternating key/value CLI arguments with regex validation.

func NewParser

func NewParser(key_regex string) (Parser, error)

NewParser compiles the provided regex and returns an initialized parser.

func (*Parser) Get

func (pars *Parser) Get(key string) (*Argument, error)

Get locates an argument by key.

func (*Parser) GetValue

func (pars *Parser) GetValue(key string) (string, error)

GetValue returns the string value for a registered argument.

func (*Parser) Parse

func (pars *Parser) Parse(args []string, strict bool) error

Parse walks the args slice and assigns discovered values to registered keys. When strict is false, unknown keys are added on the fly.

func (*Parser) Register

func (pars *Parser) Register(key string, default_value string, help string) error

Register adds a known argument with a default value and help string.

Source Files

  • Argument.go
  • Parser.go

Jump to

Keyboard shortcuts

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