decoder

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPointerToStruct = errors.New("val must be a pointer to a struct")

Functions

func IsTruthy

func IsTruthy(value string) bool

Types

type Decoder

type Decoder struct {
	Runner *interp.Runner
	// Enable distro overrides (true by default)
	Overrides bool
	// Enable using like distros for overrides
	LikeDistros bool
	// contains filtered or unexported fields
}

Decoder provides methods for decoding variable values

func New

func New(info *distro.OSRelease, runner *interp.Runner) *Decoder

New creates a new variable decoder

func (*Decoder) DecodeVar

func (d *Decoder) DecodeVar(name string, val any) error

DecodeVar decodes a variable to val using reflection. Structs should use the "sh" struct tag.

func (*Decoder) DecodeVars

func (d *Decoder) DecodeVars(val any) error

DecodeVars decodes all variables to val using reflection. Structs should use the "sh" struct tag.

func (*Decoder) GetFunc

func (d *Decoder) GetFunc(name string) (ScriptFunc, bool)

GetFunc returns a function corresponding to a bash function with the given name

func (*Decoder) GetFuncP

func (d *Decoder) GetFuncP(name string, prepare PrepareFunc) (ScriptFunc, bool)

func (*Decoder) GetFuncWithSubshell added in v0.0.7

func (d *Decoder) GetFuncWithSubshell(name string) (ScriptFuncWithSubshell, bool)

type InvalidTypeError

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

func (InvalidTypeError) Error

func (ite InvalidTypeError) Error() string

type PrepareFunc

type PrepareFunc func(context.Context, *interp.Runner) error

type ScriptFunc

type ScriptFunc func(ctx context.Context, opts ...interp.RunnerOption) error

type ScriptFuncWithSubshell added in v0.0.7

type ScriptFuncWithSubshell func(ctx context.Context, opts ...interp.RunnerOption) (*interp.Runner, error)

type VarNotFoundError

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

func (VarNotFoundError) Error

func (nfe VarNotFoundError) Error() string

Jump to

Keyboard shortcuts

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