interpreter

package
v0.0.0-...-ae9e989 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2016 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATE_NEW_CONSOLE       = 0x10
	CREATE_NEW_PROCESS_GROUP = 0x200
)

from "TDM-GCC-64/x86_64-w64-mingw32/include/winbase.h"

View Source
const EMPTY_COMMAND_FOUND = "Empty command found"
View Source
const FLAG_AMP2NEWCONSOLE = false
View Source
const NOTQUOTED = '\000'

Variables

View Source
var ErrorLevelStr string
View Source
var OnCommandNotFound = func(this *Interpreter, err error) error {
	err = &CommandNotFound{this.Args[0], err}
	return err
}
View Source
var PercentFunc = map[string]func() string{
	"CD": func() string {
		wd, err := os.Getwd()
		if err == nil {
			return wd
		} else {
			return ""
		}
	},
	"ERRORLEVEL": func() string {
		return ErrorLevelStr
	},
}

Functions

func GetErrorLevel

func GetErrorLevel(processState *os.ProcessState) (int, bool)

func OurGetEnv

func OurGetEnv(name string) (string, bool)

func Parse

func Parse(text string) ([][]*StatementT, error)

Types

type ArgsHookT

type ArgsHookT func(it *Interpreter, args []string) ([]string, error)

func SetArgsHook

func SetArgsHook(argsHook_ ArgsHookT) (rv ArgsHookT)

type CommandNotFound

type CommandNotFound struct {
	Name string
	Err  error
}

func (CommandNotFound) Error

func (this CommandNotFound) Error() string

func (CommandNotFound) Stringer

func (this CommandNotFound) Stringer() string

type ErrorLevel

type ErrorLevel int
const (
	NOERROR  ErrorLevel = 0
	THROUGH  ErrorLevel = -1
	SHUTDOWN ErrorLevel = -2
)

func (ErrorLevel) HasError

func (this ErrorLevel) HasError() bool

func (ErrorLevel) HasValue

func (this ErrorLevel) HasValue() bool

func (ErrorLevel) String

func (this ErrorLevel) String() string

type HookT

type HookT func(*Interpreter) (ErrorLevel, error)

func SetHook

func SetHook(hook_ HookT) (rv HookT)

type Interpreter

type Interpreter struct {
	exec.Cmd
	Stdio        [3]*os.File
	HookCount    int
	Closer       []io.Closer
	Tag          interface{}
	PipeSeq      [2]uint
	IsBackGround bool

	CloneHook func(*Interpreter) error
	CloseHook func(*Interpreter)
}

func New

func New() *Interpreter

func (*Interpreter) Clone

func (this *Interpreter) Clone() (*Interpreter, error)

func (*Interpreter) Close

func (this *Interpreter) Close()

func (*Interpreter) Interpret

func (this *Interpreter) Interpret(text string) (errorlevel ErrorLevel, err error)

func (*Interpreter) SetStderr

func (this *Interpreter) SetStderr(f *os.File)

func (*Interpreter) SetStdin

func (this *Interpreter) SetStdin(f *os.File)

func (*Interpreter) SetStdout

func (this *Interpreter) SetStdout(f *os.File)

func (*Interpreter) Spawnvp

func (this *Interpreter) Spawnvp() (ErrorLevel, error)

type Redirecter

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

func NewRedirecter

func NewRedirecter(no int) *Redirecter

func (*Redirecter) DupFrom

func (this *Redirecter) DupFrom(fileno int)

func (*Redirecter) FileNo

func (this *Redirecter) FileNo() int

func (*Redirecter) OpenOn

func (this *Redirecter) OpenOn(cmd *Interpreter) (*os.File, error)

func (*Redirecter) SetAppend

func (this *Redirecter) SetAppend()

func (*Redirecter) SetPath

func (this *Redirecter) SetPath(path string)

type StatementT

type StatementT struct {
	Args     []string
	Redirect []*Redirecter
	Term     string
}

Jump to

Keyboard shortcuts

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