operator

package
v0.0.0-...-466e094 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IntRegex is the regex checked for int `Args`. Underscores will be removed
	// if they are in a valid position (not the first or last character).
	IntRegex = regexp.MustCompile("^-?[0-9](_?[0-9])*?$")
)

Functions

func FromArgs

func FromArgs[T any](op Operator[T], ss ...string) (T, error)

FromArgs converts variadic basic string args to the respective type

func ParseInt

func ParseInt(s string) (int, error)

Types

type Operator

type Operator[T any] interface {
	// ToArgs converts a type to its command line equivalent
	ToArgs(T) []string
	// FromArgs converts a list of command line arguments to types
	FromArgs([]*string) (T, error)
}

Operator is an interface for mapping strings to and from specific types

func GetOperator

func GetOperator[T any]() Operator[T]

GetOperator returns an operator for type T

Jump to

Keyboard shortcuts

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