foreign

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Extensions = map[string][]Bridge{}
View Source
var Languages = map[string]Bridge{}
View Source
var Unmarshalers = map[string]Unmarshaler{}

Functions

func Register

func Register[T Bridge](i T, lang []string, ext []string)

Registrar.

func Run

func Run(path string, args ...string) (cmd *exec.Cmd, err error)

func RunContext

func RunContext(ctx context.Context, path string, args ...string) (cmd *exec.Cmd, err error)

func RunContextWith

func RunContextWith(ctx context.Context, bridge Bridge, path string, args ...string) (cmd *exec.Cmd, err error)

Utility functions.

func Unmarshal

func Unmarshal(path string, data any, out any) (err error)

func UnmarshalContext

func UnmarshalContext(ctx context.Context, path string, data any, out any) (err error)

External facing convenience functions.

func UnmarshalText

func UnmarshalText(input []byte, out any) (err error)

Types

type Bridge

type Bridge interface {
	// Run the script at the given path with the given arguments.
	Run(ctx context.Context, script string, args ...string) (cmd *exec.Cmd, err error)

	// Run the script at the given path with the given parameters, unmarshal the result into out.
	// Can also be a data format, such as JSON where the parameters are ignored.
	Unmarshal(ctx context.Context, path string, params any, out any) (err error)
}

type InlineUnmarshaler

type InlineUnmarshaler interface {
	UnmarshalInline(text string) (err error)
}

type Unmarshaler

type Unmarshaler func(input []byte, out any) (err error)

func (Unmarshaler) Register

func (u Unmarshaler) Register(ext ...string)

func (Unmarshaler) Run

func (u Unmarshaler) Run(ctx context.Context, script string, args ...string) (cmd *exec.Cmd, err error)

func (Unmarshaler) Unmarshal

func (u Unmarshaler) Unmarshal(ctx context.Context, path string, params any, out any) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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