shell

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandLine

type CommandLine struct {
	Debug bool
	// contains filtered or unexported fields
}

CommandLine is the main struct for giosh shell instance. This struct has any internal state of a shell such as lexical scopes, expressions for the evaluation, pipes which internal I/O are processed, etc.

func New

func New() CommandLine

New generates a new shell instance with default parameters.

func (*CommandLine) DumpErrors

func (c *CommandLine) DumpErrors() (isNotNilArray error)

DumpErrors is error reporting function for CommandLine. It scans any error object in CommandLine.error array and returns bool if it contains not a nil value

func (*CommandLine) GetInput

func (c *CommandLine) GetInput() string

GetInput get raw input string from c.input. (just for temporary caching for file reading)

func (*CommandLine) GetPsString

func (c *CommandLine) GetPsString() string

GetPsString returns PS shell description for bufio.Writer

func (*CommandLine) Parse

func (c *CommandLine) Parse() (err error)

Parse parses giosh command line and return output string. At now, any lexical scopes are separated with "|" and any lines are separated with EOF. (multi-line is not allowed)

func (*CommandLine) Refresh

func (c *CommandLine) Refresh()

Refresh clears basic properties for each evaluation of lexicalScopes. For bufio.Scanner, this methods clears properties related to every registered recognized lexicalScopes at the head of Parse.

func (*CommandLine) Run

func (c *CommandLine) Run() error

Run is the entry point for giosh shell interface.

If you simply run it without any additional reader/writer sets, the vm starts with default I/O interface (bufio.Scanner and os.Stdout).

func (*CommandLine) SetDebug

func (c *CommandLine) SetDebug(flag bool)

SetDebug is write-only setter method for CommandLine.Debug flag.

func (*CommandLine) SetInput

func (c *CommandLine) SetInput(input string)

SetInput sets raw input string for c.input. (for reading scripts from arguments)

func (*CommandLine) TerminateLine

func (c *CommandLine) TerminateLine(withPsString ...bool) (err error)

TerminateLine makes line termination with printing or not printing PS string Also any errors recorded in error stack will be shown by this method. FIXME: return value maybe not necessary, plan to remove it. Historically this method have a return value with error type. This is for DumpError, which have returned error object in old code

type Pipe

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

Pipe is input and output pipe for the shell. This is used to store pipe objects derived from methods on *exec.Cmd.

Jump to

Keyboard shortcuts

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