interp

package
v0.0.4-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 43 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEOF = io.EOF
View Source
var ErrInterrupt = errors.New("Interrupt")
View Source
var PlainDecorator = Decorator{
	Column:     "|",
	ValueColor: func(v interface{}) ansi.Code { return ansi.None },
	ByteColor:  func(b byte) ansi.Code { return ansi.None },
}

Functions

This section is empty.

Types

type ArrayDecodeValue

type ArrayDecodeValue struct {
	gojqextra.Base

	*decode.Compound
	// contains filtered or unexported fields
}

func NewArrayDecodeValue

func NewArrayDecodeValue(dv *decode.Value, c *decode.Compound) ArrayDecodeValue

func (ArrayDecodeValue) DecodeValue

func (dvb ArrayDecodeValue) DecodeValue() *decode.Value

func (ArrayDecodeValue) Display

func (dvb ArrayDecodeValue) Display(w io.Writer, opts Options) error

func (ArrayDecodeValue) ExtKeys

func (dvb ArrayDecodeValue) ExtKeys() []string

func (ArrayDecodeValue) ExtType added in v0.0.2

func (ArrayDecodeValue) ExtType() string

func (ArrayDecodeValue) JQValueEach

func (v ArrayDecodeValue) JQValueEach() interface{}

func (ArrayDecodeValue) JQValueHas

func (v ArrayDecodeValue) JQValueHas(key interface{}) interface{}

func (ArrayDecodeValue) JQValueIndex

func (v ArrayDecodeValue) JQValueIndex(index int) interface{}

func (ArrayDecodeValue) JQValueKey

func (v ArrayDecodeValue) JQValueKey(name string) interface{}

func (ArrayDecodeValue) JQValueKeys

func (v ArrayDecodeValue) JQValueKeys() interface{}

func (ArrayDecodeValue) JQValueLength

func (v ArrayDecodeValue) JQValueLength() interface{}

func (ArrayDecodeValue) JQValueSlice

func (v ArrayDecodeValue) JQValueSlice(start int, end int) interface{}

func (ArrayDecodeValue) JQValueSliceLen

func (v ArrayDecodeValue) JQValueSliceLen() interface{}

func (ArrayDecodeValue) JQValueToGoJQ

func (v ArrayDecodeValue) JQValueToGoJQ() interface{}

func (ArrayDecodeValue) JQValueUpdate

func (v ArrayDecodeValue) JQValueUpdate(key interface{}, u interface{}, delpath bool) interface{}

func (ArrayDecodeValue) ToBuffer

func (dvb ArrayDecodeValue) ToBuffer() (Buffer, error)

type Buffer

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

func (Buffer) Display

func (b Buffer) Display(w io.Writer, opts Options) error

func (Buffer) ExtKeys

func (Buffer) ExtKeys() []string

func (Buffer) ExtType added in v0.0.2

func (Buffer) ExtType() string

func (Buffer) JQValueEach

func (b Buffer) JQValueEach() interface{}

func (Buffer) JQValueHas

func (b Buffer) JQValueHas(key interface{}) interface{}

func (Buffer) JQValueIndex

func (b Buffer) JQValueIndex(index int) interface{}

func (Buffer) JQValueKey

func (b Buffer) JQValueKey(name string) interface{}

func (Buffer) JQValueKeys

func (b Buffer) JQValueKeys() interface{}

func (Buffer) JQValueLength

func (b Buffer) JQValueLength() interface{}

func (Buffer) JQValueSlice

func (b Buffer) JQValueSlice(start int, end int) interface{}

func (Buffer) JQValueSliceLen

func (b Buffer) JQValueSliceLen() interface{}

func (Buffer) JQValueToGoJQ

func (b Buffer) JQValueToGoJQ() interface{}

func (Buffer) JQValueToNumber

func (b Buffer) JQValueToNumber() interface{}

func (Buffer) JQValueToString

func (b Buffer) JQValueToString() interface{}

func (Buffer) JQValueType

func (b Buffer) JQValueType() string

func (Buffer) JQValueUpdate

func (b Buffer) JQValueUpdate(key interface{}, u interface{}, delpath bool) interface{}

func (Buffer) ToBuffer

func (b Buffer) ToBuffer() (Buffer, error)

type DecodeValue

type DecodeValue interface {
	Value
	ToBuffer

	DecodeValue() *decode.Value
}

TODO: redo/rename used by _isDecodeValue

type Decorator

type Decorator struct {
	Null      ansi.Code
	False     ansi.Code
	True      ansi.Code
	Number    ansi.Code
	String    ansi.Code
	ObjectKey ansi.Code
	Array     ansi.Code
	Object    ansi.Code

	Index ansi.Code
	Value ansi.Code

	DumpHeader ansi.Code
	DumpAddr   ansi.Code

	Error ansi.Code

	ValueColor func(v interface{}) ansi.Code
	ByteColor  func(b byte) ansi.Code

	Column string
}

type Display

type Display interface {
	Display(w io.Writer, opts Options) error
}

type Exiter

type Exiter interface {
	ExitCode() int
}

gojq errors can implement this to signal exit code

type FileReader

type FileReader struct {
	R        io.Reader
	FileInfo FixedFileInfo
}

func (FileReader) Close

func (FileReader) Close() error

func (FileReader) Read

func (rf FileReader) Read(p []byte) (int, error)

func (FileReader) Stat

func (rf FileReader) Stat() (fs.FileInfo, error)

type FixedFileInfo

type FixedFileInfo struct {
	FName    string
	FSize    int64
	FMode    fs.FileMode
	FModTime time.Time
	FIsDir   bool
	FSys     interface{}
}

func (FixedFileInfo) IsDir

func (ffi FixedFileInfo) IsDir() bool

func (FixedFileInfo) ModTime

func (ffi FixedFileInfo) ModTime() time.Time

func (FixedFileInfo) Mode

func (ffi FixedFileInfo) Mode() fs.FileMode

func (FixedFileInfo) Name

func (ffi FixedFileInfo) Name() string

func (FixedFileInfo) Size

func (ffi FixedFileInfo) Size() int64

func (FixedFileInfo) Sys

func (ffi FixedFileInfo) Sys() interface{}

type Function

type Function struct {
	Name     string
	MinArity int
	MaxArity int
	Fn       func(interface{}, []interface{}) interface{}
	IterFn   func(interface{}, []interface{}) gojq.Iter
}

type Input

type Input interface {
	fs.File
	Terminal
}

type Interp

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

func New

func New(os OS, registry *registry.Registry) (*Interp, error)

func (*Interp) Eval

func (i *Interp) Eval(ctx context.Context, c interface{}, src string, srcFilename string, output io.Writer) (gojq.Iter, error)

func (*Interp) EvalFunc

func (i *Interp) EvalFunc(ctx context.Context, c interface{}, name string, args []interface{}, output io.Writer) (gojq.Iter, error)

func (*Interp) EvalFuncValues

func (i *Interp) EvalFuncValues(ctx context.Context, c interface{}, name string, args []interface{}, output io.Writer) ([]interface{}, error)

func (*Interp) Main

func (i *Interp) Main(ctx context.Context, output Output, version string) error

func (*Interp) NewColorJSON

func (i *Interp) NewColorJSON(opts Options) (*colorjson.Encoder, error)

func (*Interp) Options

func (i *Interp) Options(v interface{}) Options

func (*Interp) Stop

func (i *Interp) Stop()

type IsEmptyErrorer

type IsEmptyErrorer interface {
	IsEmptyError() bool
}

gojq halt_error uses this

type JQValueEx

type JQValueEx interface {
	JQValueToGoJQEx(optsFn func() Options) interface{}
}

type OS

type OS interface {
	Stdin() Input
	Stdout() Output
	Stderr() Output
	InterruptChan() chan struct{}
	Args() []string
	Environ() []string
	ConfigDir() (string, error)
	// FS.File returned by FS().Open() can optionally implement io.Seeker
	FS() fs.FS
	Readline(prompt string, complete func(line string, pos int) (newLine []string, shared int)) (string, error)
	History() ([]string, error)
}

type Options

type Options struct {
	Depth          int    `mapstructure:"depth"`
	ArrayTruncate  int    `mapstructure:"array_truncate"`
	Verbose        bool   `mapstructure:"verbose"`
	DecodeProgress bool   `mapstructure:"decode_progress"`
	Color          bool   `mapstructure:"color"`
	Colors         string `mapstructure:"colors"`
	ByteColors     string `mapstructure:"byte_colors"`
	Unicode        bool   `mapstructure:"unicode"`
	RawOutput      bool   `mapstructure:"raw_output"`
	REPL           bool   `mapstructure:"repl"`
	RawString      bool   `mapstructure:"raw_string"`
	JoinString     string `mapstructure:"join_string"`
	Compact        bool   `mapstructure:"compact"`
	BitsFormat     string `mapstructure:"bits_format"`
	LineBytes      int    `mapstructure:"line_bytes"`
	DisplayBytes   int    `mapstructure:"display_bytes"`
	AddrBase       int    `mapstructure:"addrbase"`
	SizeBase       int    `mapstructure:"sizebase"`

	Decorator    Decorator
	BitsFormatFn func(bb *bitio.Buffer) (interface{}, error)
}

type Output

type Output interface {
	io.Writer
	Terminal
}

type RunMode

type RunMode int
const (
	ScriptMode RunMode = iota
	REPLMode
	CompletionMode
)

type StructDecodeValue

type StructDecodeValue struct {
	gojqextra.Base

	*decode.Compound
	// contains filtered or unexported fields
}

func NewStructDecodeValue

func NewStructDecodeValue(dv *decode.Value, c *decode.Compound) StructDecodeValue

func (StructDecodeValue) DecodeValue

func (dvb StructDecodeValue) DecodeValue() *decode.Value

func (StructDecodeValue) Display

func (dvb StructDecodeValue) Display(w io.Writer, opts Options) error

func (StructDecodeValue) ExtKeys

func (dvb StructDecodeValue) ExtKeys() []string

func (StructDecodeValue) ExtType added in v0.0.2

func (StructDecodeValue) ExtType() string

func (StructDecodeValue) JQValueEach

func (v StructDecodeValue) JQValueEach() interface{}

func (StructDecodeValue) JQValueHas

func (v StructDecodeValue) JQValueHas(key interface{}) interface{}

func (StructDecodeValue) JQValueKey

func (v StructDecodeValue) JQValueKey(name string) interface{}

func (StructDecodeValue) JQValueKeys

func (v StructDecodeValue) JQValueKeys() interface{}

func (StructDecodeValue) JQValueLength

func (v StructDecodeValue) JQValueLength() interface{}

func (StructDecodeValue) JQValueSliceLen

func (v StructDecodeValue) JQValueSliceLen() interface{}

func (StructDecodeValue) JQValueToGoJQ

func (v StructDecodeValue) JQValueToGoJQ() interface{}

func (StructDecodeValue) JQValueUpdate

func (v StructDecodeValue) JQValueUpdate(key interface{}, u interface{}, delpath bool) interface{}

func (StructDecodeValue) ToBuffer

func (dvb StructDecodeValue) ToBuffer() (Buffer, error)

type Terminal

type Terminal interface {
	Size() (int, int)
	IsTerminal() bool
}

type ToBuffer

type ToBuffer interface {
	ToBuffer() (Buffer, error)
}

type Value

type Value interface {
	gojq.JQValue

	ExtType() string
	ExtKeys() []string
}

type Variable

type Variable struct {
	Name  string
	Value interface{}
}

Jump to

Keyboard shortcuts

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