elvish/pkg/eval/builtin_ns.go
Qi Xiao 9112eb1ab2 Simplify how .elv files are embedded for builtin documentation.
Instead of having each individual module embed their .elv files and collect all
of them in pkg/mods/doc, have a single embed.FS at pkg that includes everything,
and use that pkg/mods/doc.

Implement a function that extracts all module elvdocs, and put it in pkg/elvdoc.
2024-01-08 16:44:35 +00:00

27 lines
727 B
Go

package eval
import (
"strconv"
"syscall"
"src.elv.sh/pkg/buildinfo"
"src.elv.sh/pkg/eval/vars"
)
var builtinNs = BuildNsNamed("").AddVars(map[string]vars.Var{
"_": vars.NewBlackhole(),
"pid": vars.NewReadOnly(strconv.Itoa(syscall.Getpid())),
"ok": vars.NewReadOnly(OK),
"nil": vars.NewReadOnly(nil),
"true": vars.NewReadOnly(true),
"false": vars.NewReadOnly(false),
"buildinfo": vars.NewReadOnly(buildinfo.Value),
"version": vars.NewReadOnly(buildinfo.Value.Version),
"paths": vars.NewEnvListVar("PATH"),
"nop" + FnSuffix: vars.NewReadOnly(nopGoFn),
})
func addBuiltinFns(fns map[string]any) {
builtinNs.AddGoFns(fns)
}