tool

package
v1.4.6 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 29 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format added in v1.0.0

func Format() error

Format formats a given set of ECAL files.

func FormatFiles added in v1.4.0

func FormatFiles(dir string, ext string) error

FormatFiles formats all ECAL files in a given directory with a given ending.

func RunPackedBinary added in v1.0.0

func RunPackedBinary()

RunPackedBinary runs ECAL code is it has been attached to the currently running binary. Exits if attached ECAL code has been executed.

Types

type CLICustomHandler added in v1.0.0

type CLICustomHandler interface {
	CLIInputHandler

	/*
	   LoadInitialFile clears the global scope and reloads the initial file.
	*/
	LoadInitialFile(tid uint64) error
}

CLICustomHandler is a handler for custom operations.

type CLIDebugInterpreter added in v1.0.0

type CLIDebugInterpreter struct {
	*CLIInterpreter

	DebugServerAddr *string // Debug server address
	RunDebugServer  *bool   // Run a debug server
	EchoDebugServer *bool   // Echo all input and output of the debug server
	Interactive     *bool   // Flag if the interpreter should open a console in the current tty.
	BreakOnStart    *bool   // Flag if the debugger should stop the execution on start
	BreakOnError    *bool   // Flag if the debugger should stop when encountering an error

	LogOut io.Writer // Log output
	// contains filtered or unexported fields
}

CLIDebugInterpreter is a commandline interpreter with debug capabilities for ECAL.

func NewCLIDebugInterpreter added in v1.0.0

func NewCLIDebugInterpreter(i *CLIInterpreter) *CLIDebugInterpreter

NewCLIDebugInterpreter wraps an existing CLIInterpreter object and adds capabilities.

func (*CLIDebugInterpreter) CanHandle added in v1.0.0

func (i *CLIDebugInterpreter) CanHandle(s string) bool

CanHandle checks if a given string can be handled by this handler.

func (*CLIDebugInterpreter) Handle added in v1.0.0

func (i *CLIDebugInterpreter) Handle(ot OutputTerminal, line string)

Handle handles a given input string.

func (*CLIDebugInterpreter) Interpret added in v1.0.0

func (i *CLIDebugInterpreter) Interpret() error

Interpret starts the ECAL code interpreter with debug capabilities.

func (*CLIDebugInterpreter) LoadInitialFile added in v1.0.0

func (i *CLIDebugInterpreter) LoadInitialFile(tid uint64) error

LoadInitialFile clears the global scope and reloads the initial file.

func (*CLIDebugInterpreter) ParseArgs added in v1.0.0

func (i *CLIDebugInterpreter) ParseArgs() bool

ParseArgs parses the command line arguments.

func (*CLIDebugInterpreter) StopDebugServer added in v1.3.3

func (i *CLIDebugInterpreter) StopDebugServer()

StopDebugServer stops the debug server if it was started.

type CLIInputHandler added in v1.0.0

type CLIInputHandler interface {

	/*
	   CanHandle checks if a given string can be handled by this handler.
	*/
	CanHandle(s string) bool

	/*
	   Handle handles a given input string.
	*/
	Handle(ot OutputTerminal, input string)
}

CLIInputHandler is a handler object for CLI input.

type CLIInterpreter added in v1.0.0

type CLIInterpreter struct {
	GlobalVS        parser.Scope                     // Global variable scope
	RuntimeProvider *interpreter.ECALRuntimeProvider // Runtime provider of the interpreter

	CustomHandler        CLICustomHandler
	CustomWelcomeMessage string
	CustomHelpString     string
	CustomRules          []*engine.Rule

	EntryFile   string // Entry file for the program
	LoadPlugins bool   // Flag if stdlib plugins should be loaded

	Dir      *string // Root dir for interpreter
	LogFile  *string // Logfile (blank for stdout)
	LogLevel *string // Log level string (Debug, Info, Error)

	Term termutil.ConsoleLineTerminal

	LogOut io.Writer
}

CLIInterpreter is a commandline interpreter for ECAL.

func NewCLIInterpreter added in v1.0.0

func NewCLIInterpreter() *CLIInterpreter

NewCLIInterpreter creates a new commandline interpreter for ECAL.

func (*CLIInterpreter) CreateRuntimeProvider added in v1.0.0

func (i *CLIInterpreter) CreateRuntimeProvider(name string) error

CreateRuntimeProvider creates the runtime provider of this interpreter. This function expects Dir, LogFile and LogLevel to be set.

func (*CLIInterpreter) CreateTerm added in v1.0.3

func (i *CLIInterpreter) CreateTerm() error

CreateTerm creates a new console terminal for stdout.

func (*CLIInterpreter) HandleInput added in v1.0.0

func (i *CLIInterpreter) HandleInput(ot OutputTerminal, line string, tid uint64)

HandleInput handles input to this interpreter. It parses a given input line and outputs on the given output terminal. Requires a thread ID of the executing thread - use the RuntimeProvider to generate a unique one.

func (*CLIInterpreter) Interpret added in v1.0.0

func (i *CLIInterpreter) Interpret(interactive bool) error

Interpret starts the ECAL code interpreter. Starts an interactive console in the current tty if the interactive flag is set.

func (*CLIInterpreter) LoadInitialFile added in v1.0.0

func (i *CLIInterpreter) LoadInitialFile(tid uint64) error

LoadInitialFile clears the global scope and reloads the initial file.

func (*CLIInterpreter) LoadStdlibPlugins added in v1.1.0

func (i *CLIInterpreter) LoadStdlibPlugins(interactive bool) error

LoadStdlibPlugins load plugins from .ecal.json.

func (*CLIInterpreter) ParseArgs added in v1.0.0

func (i *CLIInterpreter) ParseArgs() bool

ParseArgs parses the command line arguments. Call this after adding custon flags. Returns true if the program should exit.

type CLIPacker added in v1.0.0

type CLIPacker struct {
	EntryFile string // Entry file for the program

	Dir          *string // Root dir for interpreter (all files will be collected)
	SourceBinary *string // Binary which is used by the packer
	TargetBinary *string // Binary which will be build by the packer

	LogOut io.Writer
}

CLIPacker is a commandline packing tool for ECAL. This tool can build a self contained executable.

func NewCLIPacker added in v1.0.0

func NewCLIPacker() *CLIPacker

NewCLIPacker creates a new commandline packer.

func (*CLIPacker) Pack added in v1.0.0

func (p *CLIPacker) Pack() error

Pack builds a standalone executable from a given source binary and collected files.

func (*CLIPacker) ParseArgs added in v1.0.0

func (p *CLIPacker) ParseArgs() bool

ParseArgs parses the command line arguments. Returns true if the program should exit.

type OutputTerminal added in v1.0.0

type OutputTerminal interface {

	/*
	   WriteString write a string on this terminal.
	*/
	WriteString(s string)
}

OutputTerminal is a generic output terminal which can write strings.

Jump to

Keyboard shortcuts

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