scripting

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedKinds = append([]reflect.Kind{
	reflect.String,
}, numberKindsSupported...)

Functions

func CreateCollector

func CreateCollector(genType reflect.Type) (func([]string) interface{}, error)

Create a function that can take a struct

func ValidateAndSetNumber

func ValidateAndSetNumber(field reflect.StructField, structValue reflect.Value, value string) error

Validate and set a number in a struct field

func ValidateAndSetString

func ValidateAndSetString(field reflect.StructField, structValue reflect.Value, value string) error

Validate and set a string in a struct field

func ValidateNumber

func ValidateNumber(field reflect.StructField, value string) error

func ValidateString

func ValidateString(field reflect.StructField, value string) error

Validate a string based on the struct tag

Types

type CollectionField

type CollectionField struct {
	Index int
	Field huh.Field
	Set   func(reflect.Value) error
}

func CreateNumberField

func CreateNumberField(field reflect.StructField, baseField *huh.Input) CollectionField

func CreateStringField

func CreateStringField(field reflect.StructField, baseField *huh.Input) CollectionField

type Script

type Script struct {
	Name        string
	Description string
	Collector   func([]string) interface{}
	Handler     func(*mrunner.Runner, interface{}) error
}

func CreateScript

func CreateScript(name string, description string, f interface{}) Script

f must be of type func(*mrunner.Runner, T, ...) (..., error).

You can have any return types for f and the second parameter, T, can be a struct that will be dynamically generated based on CLI arguments or a CLI form. Otherwise it will be ignored. Read more about it in the documentation.

Jump to

Keyboard shortcuts

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