interp

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 44 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) ToBinary added in v0.0.5

func (dvb ArrayDecodeValue) ToBinary() (Binary, error)

type Binary added in v0.0.5

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

func (Binary) Display added in v0.0.5

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

func (Binary) ExtKeys added in v0.0.5

func (Binary) ExtKeys() []string

func (Binary) ExtType added in v0.0.5

func (Binary) ExtType() string

func (Binary) JQValueEach added in v0.0.5

func (b Binary) JQValueEach() interface{}

func (Binary) JQValueHas added in v0.0.5

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

func (Binary) JQValueIndex added in v0.0.5

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

func (Binary) JQValueKey added in v0.0.5

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

func (Binary) JQValueKeys added in v0.0.5

func (b Binary) JQValueKeys() interface{}

func (Binary) JQValueLength added in v0.0.5

func (b Binary) JQValueLength() interface{}

func (Binary) JQValueSlice added in v0.0.5

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

func (Binary) JQValueSliceLen added in v0.0.5

func (b Binary) JQValueSliceLen() interface{}

func (Binary) JQValueToGoJQ added in v0.0.5

func (b Binary) JQValueToGoJQ() interface{}

func (Binary) JQValueToNumber added in v0.0.5

func (b Binary) JQValueToNumber() interface{}

func (Binary) JQValueToString added in v0.0.5

func (b Binary) JQValueToString() interface{}

func (Binary) JQValueType added in v0.0.5

func (b Binary) JQValueType() string

func (Binary) JQValueUpdate added in v0.0.5

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

func (Binary) ToBinary added in v0.0.5

func (b Binary) ToBinary() (Binary, error)

type DecodeValue

type DecodeValue interface {
	Value
	ToBinary

	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 EvalOpts added in v0.0.5

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

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{}, expr string, opts EvalOpts) (gojq.Iter, error)

func (*Interp) EvalFunc

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

func (*Interp) EvalFuncValues

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

func (*Interp) Main

func (i *Interp) Main(ctx context.Context, output Output, versionStr 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 {
	Platform() Platform
	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(opts ReadlineOpts) (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(br bitio.ReaderAtSeeker) (interface{}, error)
}

type Output

type Output interface {
	io.Writer
	Terminal
}

type Platform added in v0.0.5

type Platform struct {
	OS   string
	Arch string
}

type ReadlineOpts added in v0.0.5

type ReadlineOpts struct {
	Prompt     string
	CompleteFn func(line string, pos int) (newLine []string, shared int)
}

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) ToBinary added in v0.0.5

func (dvb StructDecodeValue) ToBinary() (Binary, error)

type Terminal

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

type ToBinary added in v0.0.5

type ToBinary interface {
	ToBinary() (Binary, 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