stdio

package
v0.0.0-...-e081c89 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpMap

func DumpMap() (dump []string)

DumpMap returns an array of compiled builtins supporting deserialization as a key/value map (or hash)

func DumpPipes

func DumpPipes() (dump []string)

DumpPipes returns a sorted array of regestered pipes.

func DumpReadArray

func DumpReadArray() (dump []string)

DumpReadArray returns an array of compiled builtins supporting deserialization as an Array

func DumpReadArrayWithType

func DumpReadArrayWithType() (dump []string)

DumpReadArrayWithType returns an array of compiled builtins supporting deserialization as an ArrayWithType

func DumpWriteArray

func DumpWriteArray() (dump []string)

DumpWriteArray returns an array of compiled builtins supporting serialization as an Array

func ReadArray

func ReadArray(ctx context.Context, read Io, callback func([]byte)) error

ReadArray is a template function for stdio.Io

func ReadArrayWithType

func ReadArrayWithType(ctx context.Context, read Io, callback func(interface{}, string)) error

ReadArrayWithType is a template function for stdio.Io

func ReadMap

func ReadMap(read Io, config *config.Config, callback func(*Map)) error

ReadMap is a template function for stdio.Io

func RegisterPipe

func RegisterPipe(name string, constructor func(string) (Io, error))

RegisterPipe is used by pipes (/builtins/) to regester themselves to murex. This function should only be called from a packages Init() func.

func RegisterReadArray

func RegisterReadArray(dataType string, function func(ctx context.Context, read Io, callback func([]byte)) error)

RegisterReadArray is used by types (/builtins/types) to regester themselves to murex. This function should only be called from a packages Init() func.

func RegisterReadArrayWithType

func RegisterReadArrayWithType(dataType string, function func(ctx context.Context, read Io, callback func(interface{}, string)) error)

RegisterReadArrayWithType is used by types (/builtins/types) to regester themselves to murex. This function should only be called from a packages Init() func.

func RegisterReadMap

func RegisterReadMap(dataType string, function func(read Io, config *config.Config, callback func(*Map)) error)

RegisterReadMap is used by pipes (/builtins/) to regester themselves to murex. This function should only be called from a packages Init() func.

func RegisterWriteArray

func RegisterWriteArray(dataType string, function func(read Io) (ArrayWriter, error))

RegisterWriteArray is used by pipes (/builtins/) to regester themselves to murex. This function should only be called from a packages Init() func.

func WriteTo

func WriteTo(std Io, w io.Writer) (int64, error)

WriteTo is a template function for stdio.Io

func WriteToFromFile

func WriteToFromFile(f *os.File, w io.Writer) (int64, error)

WriteToFromFile is a template function for stdio.Io

Types

type ArrayWriter

type ArrayWriter interface {
	Write([]byte) error
	WriteString(string) error
	Close() error
}

ArrayWriter is a simple interface types can adopt for buffered writes of formatted arrays in structured types (eg JSON)

func WriteArray

func WriteArray(writer Io, dt string) (ArrayWriter, error)

WriteArray is a template function for stdio.Io

type Io

type Io interface {
	Stats() (uint64, uint64)

	GetDataType() string
	SetDataType(string)
	IsTTY() bool
	File() *os.File

	Read([]byte) (int, error)
	ReadLine(callback func([]byte)) error
	ReadArray(ctx context.Context, callback func([]byte)) error
	ReadArrayWithType(ctx context.Context, callback func(interface{}, string)) error
	ReadMap(*config.Config, func(*Map)) error
	ReadAll() ([]byte, error)

	Write([]byte) (int, error)
	Writeln([]byte) (int, error)
	WriteArray(string) (ArrayWriter, error)

	//ReadFrom(r io.Reader) (n int64, err error)
	WriteTo(io.Writer) (int64, error)

	Open()
	Close()
	ForceClose()
}

Io is the interface that's used for the shell functions pipelining of data eg via standard in, out and err. It is written to be compatible with Go Reader and Writer interfaces however does expand upon them with additional helper methods to enable easier writing of builtin shell functions.

func CreatePipe

func CreatePipe(pipeType, arguments string) (Io, error)

CreatePipe returns an stdio.Io interface for a specified pipe type or errors if the pipe type is invalid.

type Map

type Map struct {
	Key      string
	Value    interface{}
	DataType string
	Last     bool
}

Jump to

Keyboard shortcuts

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