github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/stdio/interface_io.go (about)

     1  package stdio
     2  
     3  import (
     4  	"context"
     5  	"io"
     6  	"os"
     7  
     8  	"github.com/lmorg/murex/config"
     9  )
    10  
    11  // Io is the interface that's used for the shell functions pipelining of data eg via standard in, out and err.
    12  // It is written to be compatible with Go Reader and Writer interfaces however does expand upon them with additional
    13  // helper methods to enable easier writing of builtin shell functions.
    14  type Io interface {
    15  	Stats() (uint64, uint64)
    16  
    17  	GetDataType() string
    18  	SetDataType(string)
    19  	IsTTY() bool
    20  	File() *os.File
    21  
    22  	Read([]byte) (int, error)
    23  	ReadLine(callback func([]byte)) error
    24  	ReadArray(ctx context.Context, callback func([]byte)) error
    25  	ReadArrayWithType(ctx context.Context, callback func(interface{}, string)) error
    26  	ReadMap(*config.Config, func(*Map)) error
    27  	ReadAll() ([]byte, error)
    28  
    29  	Write([]byte) (int, error)
    30  	Writeln([]byte) (int, error)
    31  	WriteArray(string) (ArrayWriter, error)
    32  
    33  	//ReadFrom(r io.Reader) (n int64, err error)
    34  	WriteTo(io.Writer) (int64, error)
    35  
    36  	Open()
    37  	Close()
    38  	ForceClose()
    39  }
    40  
    41  type Map struct {
    42  	Key      string
    43  	Value    interface{}
    44  	DataType string
    45  	Last     bool
    46  }