nutcracker

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: MPL-2.0 Imports: 5 Imported by: 0

README

nutcracker

a simple shell parsing and execution engine

Features

nutcracker can parse a subset of shell commands as detailed below:

Environment variables
echo $HOME ${ENVVAR:-default value}
Command substitution
echo $(cat file.txt)
String variable interpolation
"$(echo hello) $HOME ${ENVVAR:-default value}"

Documentation

Index

Constants

View Source
const (
	ErrUnclosedStrI = internalError(iota)
	ErrUnclosedStrL
	ErrUnclosedParen
	ErrUnclosedBrace
	ErrInvalidEscape
	ErrInvalidCloseParen
	ErrInvalidCloseBrace
	ErrInvalidVar
	ErrInvalidArgMode
	ErrInvalidExec
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd added in v0.1.1

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

func Parse

func Parse(shellcmd string) (*Cmd, error)

func (Cmd) Exec added in v0.1.1

func (c Cmd) Exec(env Env) error

type Env

type Env struct {
	Envvar  []string
	Envfunc EnvFunc
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
	Ex      Executor
}

type EnvFunc

type EnvFunc func(string) string

type Executor

type Executor interface {
	Exec(args []string, env Env) error
}

func NewExecutor

func NewExecutor() Executor

type Node

type Node interface {
	Value(env Env) (string, error)
}

Jump to

Keyboard shortcuts

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