Documentation ¶
Overview ¶
Package eval handles evaluation of parsed Elvish code and provides runtime facilities.
Index ¶
- Constants
- Variables
- func Cause(err error) error
- func ComposeExceptionsFromPipeline(excs []*Exception) error
- func EachExternal(f func(string))
- func GetCompilationError(e error) (*diag.Error, bool)
- func InTempHome() (string, func())
- func MustCreateEmpty(name string)
- func MustMkdirAll(name string, perm os.FileMode)
- func MustWriteFile(filename string, data []byte, perm os.FileMode)
- func NewCompilationError(message string, context diag.Context) error
- func NewExternalCmdExit(name string, ws syscall.WaitStatus, pid int) error
- func PurelyEvalCompound(cn *parse.Compound) (string, error)
- func SplitIncompleteQNameFirstNs(qname string) (ns, rest string)
- func SplitQNameNs(qname string) (ns, name string)
- func SplitQNameNsFirst(qname string) (ns, rest string)
- func SplitQNameNsIncomplete(qname string) (ns, name string)
- func SplitQNameNsSegs(qname string) []string
- func SplitVariableRef(ref string) (sigil string, qname string)
- func Styled(fm *Frame, input interface{}, stylings ...interface{}) (ui.Text, error)
- func Test(t *testing.T, tests ...TestCase)
- func TestWithSetup(t *testing.T, setup func(*Evaler), tests ...TestCase)
- type AddDirer
- type Callable
- type Closure
- func (c *Closure) Call(fm *Frame, args []interface{}, opts map[string]interface{}) error
- func (c *Closure) Equal(rhs interface{}) bool
- func (c *Closure) Hash() uint32
- func (c *Closure) Index(k interface{}) (interface{}, bool)
- func (c *Closure) IterateKeys(f func(interface{}) bool)
- func (*Closure) Kind() string
- func (c *Closure) Repr(int) string
- type Editor
- type EnvList
- type Evaler
- func (ev *Evaler) AddAfterChdir(f func(string))
- func (ev *Evaler) AddBeforeChdir(f func(string))
- func (ev *Evaler) Chdir(path string) error
- func (ev *Evaler) Close() error
- func (ev *Evaler) Compile(n *parse.Chunk, src *Source) (Op, error)
- func (ev *Evaler) CompileWithGlobal(n *parse.Chunk, src *Source, g Ns) (Op, error)
- func (ev *Evaler) EachNsInTop(f func(s string))
- func (ev *Evaler) EachVariableInTop(ns string, f func(s string))
- func (ev *Evaler) Eval(op Op, ports []*Port) error
- func (ev *Evaler) EvalInTTY(op Op) error
- func (ev *Evaler) EvalSourceInTTY(src *Source) error
- func (ev *Evaler) InstallBundled(name, src string)
- func (ev *Evaler) InstallDaemonClient(client daemon.Client)
- func (ev *Evaler) InstallModule(name string, mod Ns)
- func (ev *Evaler) PurelyEvalCompound(cn *parse.Compound) (string, error)
- func (ev *Evaler) PurelyEvalPartialCompound(cn *parse.Compound, upto *parse.Indexing) (string, error)
- func (ev *Evaler) PurelyEvalPrimary(pn *parse.Primary) interface{}
- func (ev *Evaler) SetArgs(args []string)
- func (ev *Evaler) SetLibDir(libDir string)
- type Exception
- func (exc *Exception) Bool() bool
- func (exc *Exception) Equal(rhs interface{}) bool
- func (exc *Exception) Error() string
- func (exc *Exception) Hash() uint32
- func (exc *Exception) Index(k interface{}) (interface{}, bool)
- func (exc *Exception) IterateKeys(f func(interface{}) bool)
- func (exc *Exception) Kind() string
- func (exc *Exception) PPrint(indent string) string
- func (exc *Exception) Repr(indent int) string
- type ExternalCmd
- type ExternalCmdExit
- type Flow
- type Frame
- func (fm *Frame) Call(f Callable, args []interface{}, opts map[string]interface{}) (err error)
- func (fm *Frame) CallWithOutputCallback(fn Callable, args []interface{}, opts map[string]interface{}, ...) error
- func (fm *Frame) CaptureOutput(fn Callable, args []interface{}, opts map[string]interface{}) (vs []interface{}, err error)
- func (fm *Frame) Close() error
- func (ev Frame) EachNsInTop(f func(s string))
- func (ev Frame) EachVariableInTop(ns string, f func(s string))
- func (fm *Frame) Eval(op Op) error
- func (ctx *Frame) ExecAndUnwrap(desc string, op valuesOp) ValuesUnwrapper
- func (fm *Frame) ExecWithOutputCallback(op Op, valuesCb func(<-chan interface{}), bytesCb func(*os.File)) error
- func (fm *Frame) InputChan() chan interface{}
- func (fm *Frame) InputFile() *os.File
- func (fm *Frame) Interrupts() <-chan struct{}
- func (fm *Frame) IsInterrupted() bool
- func (fm *Frame) IterateInputs(f func(interface{}))
- func (fm *Frame) OutputChan() chan<- interface{}
- func (fm *Frame) OutputFile() *os.File
- func (fm *Frame) ResolveVar(qname string) vars.Var
- func (fm *Frame) SetLocal(ns Ns)
- type GlobFlag
- type GlobPattern
- func (gp GlobPattern) Concat(v interface{}) (interface{}, error)
- func (gp GlobPattern) Equal(a interface{}) bool
- func (gp GlobPattern) Hash() uint32
- func (gp GlobPattern) Index(k interface{}) (interface{}, error)
- func (GlobPattern) Kind() string
- func (gp GlobPattern) RConcat(v interface{}) (interface{}, error)
- func (gp GlobPattern) Repr(int) string
- type GoFn
- type Inputs
- type Ns
- func (ns Ns) Add(name string, v vars.Var) Ns
- func (ns Ns) AddFn(name string, v Callable) Ns
- func (ns Ns) AddGoFn(nsName, name string, impl interface{}) Ns
- func (ns Ns) AddGoFns(nsName string, fns map[string]interface{}) Ns
- func (ns Ns) AddNs(name string, v Ns) Ns
- func (ns Ns) Clone() Ns
- func (ns Ns) Equal(rhs interface{}) bool
- func (ns Ns) HasName(name string) bool
- func (ns Ns) Hash() uint32
- func (ns Ns) Index(k interface{}) (interface{}, bool)
- func (ns Ns) IterateKeys(f func(interface{}) bool)
- func (Ns) Kind() string
- func (ns Ns) PopName(name string) vars.Var
- func (ns Ns) Repr(int) string
- type Op
- type PipelineError
- type Port
- type PwdVariable
- type RawOptions
- type Source
- type SrcType
- type TestCase
- type ValueUnwrapper
- func (u ValueUnwrapper) Any() (interface{}, error)
- func (u ValueUnwrapper) Callable() (Callable, error)
- func (u ValueUnwrapper) Fd() (int, error)
- func (u ValueUnwrapper) FdOrClose() (int, error)
- func (u ValueUnwrapper) Int() (int, error)
- func (u ValueUnwrapper) NonNegativeInt() (int, error)
- func (u ValueUnwrapper) String() (string, error)
- type ValuesUnwrapper
- Bugs
Constants ¶
const ( // FnSuffix is the suffix for the variable names of functions. Defining a // function "foo" is equivalent to setting a variable named "foo~", and vice // versa. FnSuffix = "~" // NsSuffix is the suffix for the variable names of namespaces. Defining a // namespace foo is equivalent to setting a variable named "foo:", and vice // versa. NsSuffix = ":" )
Variables ¶
var ( // ErrRelativeUseNotFromMod is thrown by "use" when relative use is used // not from a module ErrRelativeUseNotFromMod = errors.New("Relative use not from module") // ErrRelativeUseGoesOutsideLib is thrown when a relative use goes out of // the library directory. ErrRelativeUseGoesOutsideLib = errors.New("Module outside library directory") )
var ( ErrBadGlobPattern = errors.New("bad GlobPattern; elvish bug") ErrCannotDetermineUsername = errors.New("cannot determine user name from glob pattern") )
Errors thrown when globbing.
var ( ErrCanOnlyAssignList = errors.New("can only assign compatible values") ErrPathMustBeString = errors.New("path must be string") ErrPathCannotContainColonZero = errors.New(`path cannot contain colon or \0`) )
Errors
var ( // ErrExternalCmdOpts is thrown when an external command is passed Elvish // options. // // TODO: Catch this kind of errors at compilation time. ErrExternalCmdOpts = errors.New("external commands don't accept elvish options") // ErrImplicitCdNoArg is thrown when an implicit cd form is passed arguments. ErrImplicitCdNoArg = errors.New("implicit cd accepts no arguments") )
var ( ErrMustFollowWildcard = errors.New("must follow wildcard") ErrModifierMustBeString = errors.New("modifier must be string") ErrWildcardNoMatch = errors.New("wildcard has no match") )
var ( // ErrArgs is thrown when a Go function gets erroneous arguments. // // TODO(xiaq): Replace this single error type with multiple types that carry // richer error information. ErrArgs = errors.New("args error") // ErrNoOptAccepted is thrown when a Go function that does not accept any // options gets passed options. ErrNoOptAccepted = errors.New("function does not accept any options") )
var ( // ClosedChan is a closed channel, suitable for use as placeholder channel input. ClosedChan = make(chan interface{}) // BlackholeChan is channel writes onto which disappear, suitable for use as // placeholder channel output. BlackholeChan = make(chan interface{}) // DevNull is /dev/null. DevNull *os.File // DevNullClosedChan is a port made up from DevNull and ClosedChan, // suitable as placeholder input port. DevNullClosedChan *Port )
var ( // NoArgs is an empty argument list. It can be used as an argument to Call. NoArgs = []interface{}{} // NoOpts is an empty option map. It can be used as an argument to Call. NoOpts = map[string]interface{}{} )
var ErrArityMismatch = errors.New("arity mismatch")
ErrArityMismatch is thrown by a closure when the number of arguments the user supplies does not match with what is required.
var ErrBadBase = errors.New("bad base")
ErrBadBase is thrown by the "base" builtin if the base is smaller than 2 or greater than 36.
var ErrImpure = errors.New("expression is impure")
var ErrInputOfEawkMustBeString = errors.New("input of eawk must be string")
ErrInputOfEawkMustBeString is thrown when eawk gets a non-string input.
var ErrInterrupted = errors.New("interrupted")
ErrInterrupted is thrown when the execution is interrupted by a signal.
var ErrMoreThanOneRest = errors.New("more than one @ lvalue")
ErrMoreThanOneRest is returned when the LHS of an assignment contains more than one rest variables.
var ErrNotInSameProcessGroup = errors.New("not in the same process group")
ErrNotInSameProcessGroup is thrown when the process IDs passed to fg are not in the same process group.
var ErrStoreNotConnected = errors.New("store not connected")
ErrStoreNotConnected is thrown by dir-history when the store is not connected.
var IsBuiltinSpecial = map[string]bool{}
IsBuiltinSpecial is the set of all names of builtin special forms. It is intended for external consumption, e.g. the syntax highlighter.
var OK = &Exception{}
OK is a pointer to the zero value of Exception, representing the absence of exception.
Functions ¶
func Cause ¶
Cause returns the Cause field if err is an *Exception. Otherwise it returns err itself.
func ComposeExceptionsFromPipeline ¶
ComposeExceptionsFromPipeline takes a slice of Exception pointers and composes a suitable error. If all elements of the slice are either nil or OK, a nil is returned. If there is exactly non-nil non-OK Exception, it is returned. Otherwise, a PipelineError built from the slice is returned, with nil items turned into OK's for easier access from elvishscript.
func EachExternal ¶
func EachExternal(f func(string))
EachExternal calls f for each name that can resolve to an external command. TODO(xiaq): Windows support
func GetCompilationError ¶
GetCompilationError returns a *diag.Error and true if the given error is a compilation error. Otherwise it returns nil and false.
func InTempHome ¶
func InTempHome() (string, func())
InTempHome is like util.InTestDir, but it also sets HOME to the temporary directory and restores the original HOME in cleanup.
TODO(xiaq): Move this into the util package.
func MustCreateEmpty ¶
func MustCreateEmpty(name string)
MustCreateEmpty creates an empty file, and panics if an error occurs. It is mainly useful in tests.
func MustMkdirAll ¶
MustMkdirAll calls os.MkdirAll and panics if an error is returned. It is mainly useful in tests.
func MustWriteFile ¶
MustWriteFile calls ioutil.WriteFile and panics if an error occurs. It is mainly useful in tests.
func NewCompilationError ¶
NewCompilationError creates a new compilation error.
func NewExternalCmdExit ¶
func NewExternalCmdExit(name string, ws syscall.WaitStatus, pid int) error
NewExternalCmdExit constructs an error for representing a non-zero exit from an external command.
func SplitIncompleteQNameFirstNs ¶
SplitIncompleteQNameNsFirst splits an incomplete qualified variable name into the first part and the rest.
func SplitQNameNs ¶
SplitQNameNs splits a qualified variable name into the namespace part and the name part.
func SplitQNameNsFirst ¶
SplitQNameNs splits a qualified variable name into the first part and the rest.
func SplitQNameNsIncomplete ¶
SplitQNameNs splits an incomplete qualified variable name into the namespace part and the name part.
func SplitQNameNsSegs ¶
SplitQNameNsSegs splits a qualified name into namespace segments.
func SplitVariableRef ¶
SplitVariableRef splits a variable reference into the sigil and the (qualified) name.
func Styled ¶
Styled turns a string, a ui.Segment or a ui.Text into a ui.Text by applying the given stylings.
Types ¶
type AddDirer ¶
type AddDirer interface { // AddDir adds a directory with the given weight to some storage. AddDir(dir string, weight float64) error }
AddDirer wraps the AddDir function.
type Callable ¶
type Callable interface { // Call calls the receiver in a Frame with arguments and options. Call(fm *Frame, args []interface{}, opts map[string]interface{}) error }
Callable wraps the Call method.
type Closure ¶
type Closure struct { ArgNames []string // The name for the rest argument. If empty, the function has fixed arity. RestArg string OptNames []string OptDefaults []interface{} Op effectOp Captured Ns SrcMeta *Source DefBegint int DefEnd int }
Closure is a closure defined in Elvish script. Each closure has its unique identity.
func (*Closure) Index ¶
Index supports the introspection of the closure. Supported keys are "arg-names", "rest-arg", "opt-names", "opt-defaults", "body", "def" and "src".
func (*Closure) IterateKeys ¶
IterateKeys calls f with all the valid keys that can be used for Index.
type Editor ¶
type Editor interface {
Notify(string, ...interface{})
}
Editor is the interface that the line editor has to satisfy. It is needed so that this package does not depend on the edit package.
type EnvList ¶
EnvList is a variable whose value is constructed from an environment variable by splitting at pathListSeparator. Changes to it are also propagated to the corresponding environment variable. Its elements cannot contain pathListSeparator or \0; attempting to put any in its elements will result in an error.
type Evaler ¶
type Evaler struct { // Dependencies. // // TODO: Remove these dependency by providing more general extension points. DaemonClient daemon.Client Editor Editor // contains filtered or unexported fields }
Evaler is used to evaluate elvish sources. It maintains runtime context shared among all evalCtx instances.
func (*Evaler) AddAfterChdir ¶
AddAfterChdir adds a function to run after changing directory.
func (*Evaler) AddBeforeChdir ¶
AddBeforeChdir adds a function to run before changing directory.
func (*Evaler) Chdir ¶
Chdir changes the current directory. On success it also updates the PWD environment variable and records the new directory in the directory history. It runs the functions in beforeChdir immediately before changing the directory, and the functions in afterChdir immediately after (if chdir was successful). It returns nil as long as the directory changing part succeeds.
func (*Evaler) Close ¶
Close releases resources allocated when creating this Evaler. Currently this does nothing and always returns a nil error.
func (*Evaler) Compile ¶
Compile compiles Elvish code in the global scope. If the error is not nil, it can be passed to GetCompilationError to retrieve more details.
func (*Evaler) CompileWithGlobal ¶
CompileWithGlobal compiles Elvish code in an alternative global scope. If the error is not nil, it can be passed to GetCompilationError to retrieve more details.
TODO(xiaq): To use the Op created, the caller must create a Frame and mutate its local scope manually. Consider restructuring the API to make that unnecessary.
func (*Evaler) EachNsInTop ¶
func (ev *Evaler) EachNsInTop(f func(s string))
EachNsInTop calls the passed function for each namespace that can be used from the top context.
func (*Evaler) EachVariableInTop ¶
EachVariableInTop calls the passed function for each variable name in namespace ns that can be found from the top context.
func (*Evaler) EvalInTTY ¶
EvalInTTY evaluates an Op in the current terminal. It uses the stdin, stdout and stderr to build the ports, relays SIGINT from the terminal to ev.intCh, and puts Elvish in the foreground after evaluation finishes.
TODO(xiaq): This function can only be used to evaluate an Op, and cannot be used to call functions with stdPorts. Make the Evaler initialize a stdPorts on construction, instead of in this function, so that NewTopFrame does not require the caller to supply the ports.
func (*Evaler) EvalSourceInTTY ¶
EvalSourceInTTY evaluates Elvish source code in the current terminal.
func (*Evaler) InstallBundled ¶
InstallBundled installs a bundled module to the Evaler.
func (*Evaler) InstallDaemonClient ¶
InstallDaemonClient installs a daemon client to the Evaler.
func (*Evaler) InstallModule ¶
InstallModule installs a module to the Evaler so that it can be used with "use $name" from script.
func (*Evaler) PurelyEvalCompound ¶
func (*Evaler) PurelyEvalPartialCompound ¶
func (*Evaler) PurelyEvalPrimary ¶
PurelyEvalPrimary evaluates a primary node without causing any side effects. If this cannot be done, it returns nil.
Currently, only string literals and variables with no @ can be evaluated.
type Exception ¶
type Exception struct { Cause error Traceback *stackTrace }
Exception represents an elvish exception. It is both a Value accessible to elvishscript, and the type of error returned by public facing evaluation methods like (*Evaler)PEval.
func (*Exception) Index ¶
Index supports introspection of the exception. Currently the only supported key is "cause".
func (*Exception) IterateKeys ¶
IterateKeys calls f with all the valid keys that can be used in Index.
type ExternalCmd ¶
type ExternalCmd struct {
Name string
}
ExternalCmd is an external command.
func (ExternalCmd) Call ¶
func (e ExternalCmd) Call(fm *Frame, argVals []interface{}, opts map[string]interface{}) error
Call calls an external command.
func (ExternalCmd) Equal ¶
func (e ExternalCmd) Equal(a interface{}) bool
func (ExternalCmd) Hash ¶
func (e ExternalCmd) Hash() uint32
func (ExternalCmd) Kind ¶
func (ExternalCmd) Kind() string
func (ExternalCmd) Repr ¶
func (e ExternalCmd) Repr(int) string
type ExternalCmdExit ¶
type ExternalCmdExit struct { syscall.WaitStatus CmdName string Pid int }
ExternalCmdExit contains the exit status of external commands. If the command was stopped rather than terminated, the Pid field contains the pid of the process.
func (ExternalCmdExit) Error ¶
func (exit ExternalCmdExit) Error() string
type Frame ¶
type Frame struct { *Evaler // contains filtered or unexported fields }
Frame contains information of the current running function, aknin to a call frame in native CPU execution. A Frame is only modified during and very shortly after creation; new Frame's are "forked" when needed.
func NewTopFrame ¶
NewTopFrame creates a top-level Frame.
TODO(xiaq): This should be a method on the Evaler.
func (*Frame) Call ¶
Call calls a function with the given arguments and options. It does so in a protected environment so that exceptions thrown are wrapped in an Error.
func (*Frame) CallWithOutputCallback ¶
func (fm *Frame) CallWithOutputCallback(fn Callable, args []interface{}, opts map[string]interface{}, valuesCb func(<-chan interface{}), bytesCb func(*os.File)) error
CallWithOutputCallback calls a function with the given arguments and options, feeding the outputs to the given callbacks. It does so in a protected environment so that exceptions thrown are wrapped in an Error.
func (*Frame) CaptureOutput ¶
func (fm *Frame) CaptureOutput(fn Callable, args []interface{}, opts map[string]interface{}) (vs []interface{}, err error)
CaptureOutput calls a function with the given arguments and options, capturing and returning the output. It does so in a protected environment so that exceptions thrown are wrapped in an Error.
func (*Frame) Close ¶
Close releases resources allocated for this frame. It always returns a nil error. It may be called only once.
func (Frame) EachNsInTop ¶
func (ev Frame) EachNsInTop(f func(s string))
EachNsInTop calls the passed function for each namespace that can be used from the top context.
func (Frame) EachVariableInTop ¶
EachVariableInTop calls the passed function for each variable name in namespace ns that can be found from the top context.
func (*Frame) Eval ¶
Eval evaluates an Op. It is like eval except that it sets fm.srcMeta temporarily to op.src during the evaluation.
func (*Frame) ExecAndUnwrap ¶
func (ctx *Frame) ExecAndUnwrap(desc string, op valuesOp) ValuesUnwrapper
ExecAndUnwrap executes a ValuesOp and creates an Unwrapper for the obtained values.
func (*Frame) ExecWithOutputCallback ¶
func (fm *Frame) ExecWithOutputCallback(op Op, valuesCb func(<-chan interface{}), bytesCb func(*os.File)) error
ExecWithOutputCallback executes an Op, feeding the outputs to the given callbacks.
func (*Frame) InputChan ¶
func (fm *Frame) InputChan() chan interface{}
InputChan returns a channel from which input can be read.
func (*Frame) Interrupts ¶
func (fm *Frame) Interrupts() <-chan struct{}
Interrupts returns a channel that is closed when an interrupt signal comes.
func (*Frame) IsInterrupted ¶
IsInterrupted reports whether there has been an interrupt.
func (*Frame) IterateInputs ¶
func (fm *Frame) IterateInputs(f func(interface{}))
IterateInputs calls the passed function for each input element.
func (*Frame) OutputChan ¶
func (fm *Frame) OutputChan() chan<- interface{}
OutputChan returns a channel onto which output can be written.
func (*Frame) OutputFile ¶
OutputFile returns a file onto which output can be written.
func (*Frame) ResolveVar ¶
ResolveVar resolves a variable. When the variable cannot be found, nil is returned.
type GlobPattern ¶
GlobPattern is en ephemeral Value generated when evaluating tilde and wildcards.
func (GlobPattern) Concat ¶
func (gp GlobPattern) Concat(v interface{}) (interface{}, error)
func (GlobPattern) Equal ¶
func (gp GlobPattern) Equal(a interface{}) bool
func (GlobPattern) Hash ¶
func (gp GlobPattern) Hash() uint32
func (GlobPattern) Index ¶
func (gp GlobPattern) Index(k interface{}) (interface{}, error)
func (GlobPattern) Kind ¶
func (GlobPattern) Kind() string
func (GlobPattern) RConcat ¶
func (gp GlobPattern) RConcat(v interface{}) (interface{}, error)
func (GlobPattern) Repr ¶
func (gp GlobPattern) Repr(int) string
type GoFn ¶
type GoFn struct {
// contains filtered or unexported fields
}
GoFn uses reflection to wrap arbitrary Go functions into Elvish functions.
Parameters are passed following these rules:
1. If the first parameter of function has type *Frame, it gets the current call frame.
2. If (possibly after a *Frame parameter) the first parameter has type RawOptions, it gets a map of options. If the function has not declared an RawOptions parameter but is passed options, an error is thrown.
Alternatively, a (non-pointer) struct argument whose type implements the Options interface can also be declared, in which case options will be scanned into it using RawOptions.Scan. If the pointer type of the struct implements a SetDefault method, it will be called before scanning.
3. If the last parameter is non-variadic and has type Inputs, it represents an optional parameter that contains the input to this function. If the argument is not supplied, the input channel of the Frame will be used to supply the inputs.
4. Other parameters are converted using elvToGo.
Return values go to the channel part of the stdout port, after being converted using goToElv. If the last return value has type error and is not nil, it is turned into an exception and no ouputting happens. If the last return value is a nil error, it is ignored.
type Inputs ¶
type Inputs func(func(interface{}))
Inputs is the type that the last parameter of a Go-native function can take. When that is the case, it is a callback to get inputs. See the doc of GoFn for details.
type Ns ¶
Ns is a map from names to variables.
func (Ns) IterateKeys ¶
type Op ¶
type Op struct { Inner effectOp Src *Source }
Op represents an operation on a Frame. It is the result of compiling a piece of source.
type PipelineError ¶
type PipelineError struct {
Errors []*Exception
}
PipelineError represents the errors of pipelines, in which multiple commands may error.
func (PipelineError) Error ¶
func (pe PipelineError) Error() string
Error returns a plain text representation of the pipeline error.
func (PipelineError) Repr ¶
func (pe PipelineError) Repr(indent int) string
Repr returns a representation of the pipeline error, using the multi-error builtin.
type PwdVariable ¶
type PwdVariable struct {
// contains filtered or unexported fields
}
PwdVariable is a variable whose value always reflects the current working directory. Setting it changes the current working directory.
func (PwdVariable) Get ¶
func (PwdVariable) Get() interface{}
Get returns the current working directory. It returns /unknown/pwd when it cannot be determined.
func (PwdVariable) Set ¶
func (pwd PwdVariable) Set(v interface{}) error
Set changes the current working directory.
type RawOptions ¶
type RawOptions map[string]interface{}
RawOptions is the type of an argument a Go-native function can take to declare that it wants to parse options itself. See the doc of GoFn for details.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source describes a piece of source code.
func NewInteractiveSource ¶
NewInteractiveSource returns a Source for a piece of code entered interactively.
func NewInternalSource ¶
func NewModuleSource ¶
NewModuleSource returns a Source for a piece of code used as a module.
func NewScriptSource ¶
NewScriptSource returns a Source for a piece of code used as a script.
func (*Source) IterateKeys ¶
type SrcType ¶
type SrcType int
SrcType records the type of a piece of source code.
const ( // SrcInternal is a special SrcType for internal operations. SrcInternal SrcType = iota // SrcInteractive is the type of source code entered interactively. SrcInteractive // SrcScript is the type of source code used as a script. SrcScript // SrcModule is the type of source code used as a module. SrcModule )
type TestCase ¶
type TestCase struct {
// contains filtered or unexported fields
}
TestCase is a test case for Test.
func (TestCase) DoesNothing ¶
DoesNothing returns t unchanged. It is used to mark that a piece of code should simply does nothing. In particular, it shouldn't have any output and does not error.
func (TestCase) Errors ¶
Errors returns an altered Test that requires the source code to result in any error when evaluated.
func (TestCase) ErrorsWith ¶
ErrorsWith returns an altered Test that requires the source code to result in the specified error when evaluted.
func (TestCase) Prints ¶
Prints returns an altered test that requires the source code to produce the specified output in the byte pipe when evaluated.
func (TestCase) Puts ¶
Puts returns an altered Test that requires the source code to produce the specified values in the value channel when evaluated.
func (TestCase) PutsStrings ¶
PutsStrings returns an altered Test that requires the source code to produce the specified strings in the value channel when evaluated.
type ValueUnwrapper ¶
type ValueUnwrapper struct {
// contains filtered or unexported fields
}
ValueUnwrapper unwraps one Value.
func (ValueUnwrapper) Any ¶
func (u ValueUnwrapper) Any() (interface{}, error)
func (ValueUnwrapper) Callable ¶
func (u ValueUnwrapper) Callable() (Callable, error)
func (ValueUnwrapper) Fd ¶
func (u ValueUnwrapper) Fd() (int, error)
func (ValueUnwrapper) FdOrClose ¶
func (u ValueUnwrapper) FdOrClose() (int, error)
func (ValueUnwrapper) Int ¶
func (u ValueUnwrapper) Int() (int, error)
func (ValueUnwrapper) NonNegativeInt ¶
func (u ValueUnwrapper) NonNegativeInt() (int, error)
func (ValueUnwrapper) String ¶
func (u ValueUnwrapper) String() (string, error)
type ValuesUnwrapper ¶
type ValuesUnwrapper struct {
// contains filtered or unexported fields
}
ValuesUnwrapper unwraps []Value.
func (ValuesUnwrapper) One ¶
func (u ValuesUnwrapper) One() ValueUnwrapper
One unwraps the value to be exactly one value.
Notes ¶
Bugs ¶
When evaluating closures, async access to global variables and ports can be problematic.
Source Files ¶
- args_walker.go
- boilerplate.go
- builtin_fn_cmd.go
- builtin_fn_cmd_unix.go
- builtin_fn_container.go
- builtin_fn_debug.go
- builtin_fn_env.go
- builtin_fn_flow.go
- builtin_fn_fs.go
- builtin_fn_io.go
- builtin_fn_misc.go
- builtin_fn_num.go
- builtin_fn_pred.go
- builtin_fn_str.go
- builtin_fn_styled.go
- builtin_ns.go
- builtin_special.go
- chdir.go
- closure.go
- compilation_error.go
- compile_effect.go
- compile_lvalue.go
- compile_value.go
- compiler.go
- editor.go
- env_list.go
- eval.go
- exception.go
- external_cmd.go
- frame.go
- glob.go
- go_fn.go
- interrupts.go
- must.go
- ns.go
- op.go
- options.go
- port.go
- process_unix.go
- purely_eval.go
- pwd.go
- resolve.go
- source.go
- stacktrace.go
- state.go
- std_ports.go
- testutils.go
- unwrap.go
- value.go
- variable_ref.go
Directories ¶
Path | Synopsis |
---|---|
Package bundled keeps bundled modules.
|
Package bundled keeps bundled modules. |
Package daemon implements the builtin daemon: module.
|
Package daemon implements the builtin daemon: module. |
Package re implements a regular expression module.
|
Package re implements a regular expression module. |
Package str exposes functionality from Go's strings package as an Elvish module.
|
Package str exposes functionality from Go's strings package as an Elvish module. |
Package vals contains basic facilities for manipulating values used in the Elvish runtime.
|
Package vals contains basic facilities for manipulating values used in the Elvish runtime. |
Package vars contains basic types for manipulating Elvish variables.
|
Package vars contains basic types for manipulating Elvish variables. |