internal

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arguments

type Arguments = map[string]string

type BasicScanner

type BasicScanner interface {
	Scan(prompt string) bool
	Text() string
	Err() error
}

A basic scanner interface

type Context

type Context struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewContext

func NewContext() *Context

func (*Context) GetAllVars

func (ctx *Context) GetAllVars() (all Arguments)

GetAllVars return a copy of all variables available at the current scope

func (*Context) GetScope

func (ctx *Context) GetScope(scope Scope) Arguments

GetScope returns the variable sets for the specified scope

func (*Context) GetVar

func (ctx *Context) GetVar(k string) (string, bool)

GetVar return the value of the specified variable from the closest scope

func (*Context) GetVarNames

func (ctx *Context) GetVarNames() (names []string)

GetAllVars return a copy of all variables available at the current scope

func (*Context) PopScope

func (ctx *Context) PopScope()

PopScope removes the current scope, restoring the previous one

func (*Context) PushScope

func (ctx *Context) PushScope(vars map[string]string, args []string)

PushScope pushes a new scope for variables, with the associated dvalues

func (*Context) ReadBlock

func (ctx *Context) ReadBlock(body, next, cont string) ([]string, []string, error)

func (*Context) ReadLine

func (ctx *Context) ReadLine(prompt, cont string) (line string, err error)

func (*Context) ResetTerminal

func (ctx *Context) ResetTerminal()

func (*Context) RestoreMode

func (ctx *Context) RestoreMode(m liner.ModeApplier)

func (*Context) ScanBlock

func (ctx *Context) ScanBlock(block []string) BasicScanner

ScanBlock sets the current scanner to a block scanner

func (*Context) ScanLiner

func (ctx *Context) ScanLiner() BasicScanner

ScanLiner sets the current scanner to a "liner" scanner

func (*Context) ScanReader

func (ctx *Context) ScanReader(r io.Reader) BasicScanner

ScanReader sets the current scanner to an io.Reader scanner

func (*Context) SetScanner

func (ctx *Context) SetScanner(curr BasicScanner) (prev BasicScanner)

SetScanner sets the current scanner and return the previos one

func (*Context) SetVar

func (ctx *Context) SetVar(k string, v interface{}, scope Scope)

SetVar sets a variable in the current, parent or global scope

func (*Context) SetWordCompleter

func (ctx *Context) SetWordCompleter(completer func(line string, pos int) (head string, completions []string, tail string))

func (*Context) ShiftArgs

func (ctx *Context) ShiftArgs(n int)

func (*Context) StartLiner

func (ctx *Context) StartLiner(history string)

func (*Context) StopLiner

func (ctx *Context) StopLiner()

func (*Context) TerminalMode

func (ctx *Context) TerminalMode() (liner.ModeApplier, error)

func (*Context) UnsetVar

func (ctx *Context) UnsetVar(k string, scope Scope)

UnsetVar removes a variable from the current, parent or global scope

func (*Context) UpdateHistory

func (ctx *Context) UpdateHistory(line string)

func (*Context) UpdateVar

func (ctx *Context) UpdateVar(k string, scope Scope, update func(string) interface{}) string

UpdateVar allows to atomically change the valua of a variable. The `update` callback receives the current value and should returns the new value.

type Dict

type Dict = map[string]interface{}

type List

type List = []interface{}

type ScanLiner

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

An implementation of basicScanner that works with "liner"

func (*ScanLiner) Err

func (s *ScanLiner) Err() error

func (*ScanLiner) Scan

func (s *ScanLiner) Scan(prompt string) bool

func (*ScanLiner) Text

func (s *ScanLiner) Text() string

type ScanLines

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

An implementation of basicScanner that works on a list of lines

func (*ScanLines) Err

func (s *ScanLines) Err() (err error)

func (*ScanLines) Scan

func (s *ScanLines) Scan(prompt string) bool

func (*ScanLines) Text

func (s *ScanLines) Text() (text string)

type ScanReader

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

An implementation of basicScanner that works with an io.Reader (wrapped in a bufio.Scanner)

func (*ScanReader) Err

func (s *ScanReader) Err() error

func (*ScanReader) Scan

func (s *ScanReader) Scan(prompt string) bool

func (*ScanReader) Text

func (s *ScanReader) Text() string

type Scope

type Scope int
const (
	InvalidScope Scope = iota
	LocalScope
	ParentScope
	GlobalScope
)

func (Scope) String

func (s Scope) String() string

Jump to

Keyboard shortcuts

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