mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "3cafbe8c4ff05479d902d1b331b27a76918b0b72" and "f9133584d49b901e301961768b7865ab0801a881" have entirely different histories.
3cafbe8c4f
...
f9133584d4
|
@ -1,6 +1,5 @@
|
||||||
*.exe
|
*.exe
|
||||||
hilbish
|
hilbish
|
||||||
docgen
|
|
||||||
|
|
||||||
.vim
|
.vim
|
||||||
petals/
|
petals/
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"path/filepath"
|
|
||||||
"go/ast"
|
|
||||||
"go/doc"
|
|
||||||
"go/parser"
|
|
||||||
"go/token"
|
|
||||||
"strings"
|
|
||||||
"os"
|
|
||||||
)
|
|
||||||
|
|
||||||
// feel free to clean this up
|
|
||||||
// it works, dont really care about the code
|
|
||||||
func main() {
|
|
||||||
fset := token.NewFileSet()
|
|
||||||
|
|
||||||
dirs := []string{"./"}
|
|
||||||
filepath.Walk("golibs/", func (path string, info os.FileInfo, err error) error {
|
|
||||||
if !info.IsDir() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
dirs = append(dirs, "./" + path)
|
|
||||||
return nil
|
|
||||||
})
|
|
||||||
|
|
||||||
pkgs := make(map[string]*ast.Package)
|
|
||||||
for _, path := range dirs {
|
|
||||||
d, err := parser.ParseDir(fset, path, nil, parser.ParseComments)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for k, v := range d {
|
|
||||||
pkgs[k] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prefix := map[string]string{
|
|
||||||
"main": "hsh",
|
|
||||||
"hilbish": "hl",
|
|
||||||
"fs": "f",
|
|
||||||
"commander": "c",
|
|
||||||
"bait": "b",
|
|
||||||
}
|
|
||||||
docs := make(map[string][]string)
|
|
||||||
|
|
||||||
for l, f := range pkgs {
|
|
||||||
p := doc.New(f, "./", doc.AllDecls)
|
|
||||||
for _, t := range p.Funcs {
|
|
||||||
mod := l
|
|
||||||
if strings.HasPrefix(t.Name, "hl") { mod = "hilbish" }
|
|
||||||
if !strings.HasPrefix(t.Name, prefix[mod]) || t.Name == "Loader" { continue }
|
|
||||||
parts := strings.Split(t.Doc, "\n")
|
|
||||||
funcsig := parts[0]
|
|
||||||
doc := parts[1:]
|
|
||||||
|
|
||||||
docs[mod] = append(docs[mod], funcsig + " > " + strings.Join(doc, "\n"))
|
|
||||||
}
|
|
||||||
for _, t := range p.Types {
|
|
||||||
for _, m := range t.Methods {
|
|
||||||
if !strings.HasPrefix(m.Name, prefix[l]) || m.Name == "Loader" { continue }
|
|
||||||
parts := strings.Split(m.Doc, "\n")
|
|
||||||
funcsig := parts[0]
|
|
||||||
doc := parts[1:]
|
|
||||||
|
|
||||||
docs[l] = append(docs[l], funcsig + " > " + strings.Join(doc, "\n"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for mod, v := range docs {
|
|
||||||
if mod == "main" { mod = "global" }
|
|
||||||
os.Mkdir("docs", 0744)
|
|
||||||
f, _ := os.Create("docs/" + mod + ".txt")
|
|
||||||
f.WriteString(strings.Join(v, "\n") + "\n")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,6 @@
|
||||||
package bait
|
package bait
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"hilbish/util"
|
|
||||||
|
|
||||||
"github.com/chuckpreslar/emission"
|
"github.com/chuckpreslar/emission"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"layeh.com/gopher-luar"
|
"layeh.com/gopher-luar"
|
||||||
|
@ -20,24 +18,18 @@ func New() Bait {
|
||||||
|
|
||||||
func (b *Bait) Loader(L *lua.LState) int {
|
func (b *Bait) Loader(L *lua.LState) int {
|
||||||
mod := L.SetFuncs(L.NewTable(), map[string]lua.LGFunction{})
|
mod := L.SetFuncs(L.NewTable(), map[string]lua.LGFunction{})
|
||||||
L.SetField(mod, "throw", luar.New(L, b.bthrow))
|
L.SetField(mod, "throw", luar.New(L, b.throw))
|
||||||
L.SetField(mod, "catch", luar.New(L, b.bcatch))
|
L.SetField(mod, "catch", luar.New(L, b.catch))
|
||||||
|
|
||||||
util.Document(L, mod, `Bait is the event emitter for Hilbish. Why name it bait? Because it throws hooks that you can catch. (emits events that you can listen to) and because why not, fun naming is fun.
|
|
||||||
This is what you will use if you want to listen in on hooks to know when certain things have happened, like when you've changed directory, a command has failed, etc.`)
|
|
||||||
L.Push(mod)
|
L.Push(mod)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// throw(name, ...args)
|
func (b *Bait) throw(name string, args ...interface{}) {
|
||||||
// Throws a hook with `name` with the provided `args`
|
|
||||||
func (b *Bait) bthrow(name string, args ...interface{}) {
|
|
||||||
b.Em.Emit(name, args...)
|
b.Em.Emit(name, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// catch(name, cb)
|
func (b *Bait) catch(name string, catcher func(...interface{})) {
|
||||||
// Catches a hook with `name`. Runs the `cb` when it is thrown
|
|
||||||
func (b *Bait) bcatch(name string, catcher func(...interface{})) {
|
|
||||||
b.Em.On(name, catcher)
|
b.Em.On(name, catcher)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package commander
|
package commander
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"hilbish/util"
|
|
||||||
|
|
||||||
"github.com/chuckpreslar/emission"
|
"github.com/chuckpreslar/emission"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
)
|
)
|
||||||
|
@ -19,19 +17,17 @@ func New() Commander {
|
||||||
|
|
||||||
func (c *Commander) Loader(L *lua.LState) int {
|
func (c *Commander) Loader(L *lua.LState) int {
|
||||||
var exports = map[string]lua.LGFunction{
|
var exports = map[string]lua.LGFunction{
|
||||||
"register": c.cregister,
|
"register": c.register,
|
||||||
"deregister": c.cderegister,
|
"deregister": c.deregister,
|
||||||
}
|
}
|
||||||
mod := L.SetFuncs(L.NewTable(), exports)
|
mod := L.SetFuncs(L.NewTable(), exports)
|
||||||
util.Document(L, mod, "Commander is Hilbish's custom command library, a way to write commands with the shell in Lua.")
|
|
||||||
L.Push(mod)
|
L.Push(mod)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// register(name, cb)
|
func (c *Commander) register(L *lua.LState) int {
|
||||||
// Register a command with `name` that runs `cb` when ran
|
|
||||||
func (c *Commander) cregister(L *lua.LState) int {
|
|
||||||
cmdName := L.CheckString(1)
|
cmdName := L.CheckString(1)
|
||||||
cmd := L.CheckFunction(2)
|
cmd := L.CheckFunction(2)
|
||||||
|
|
||||||
|
@ -40,9 +36,7 @@ func (c *Commander) cregister(L *lua.LState) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// deregister(name)
|
func (c *Commander) deregister(L *lua.LState) int {
|
||||||
// Deregisters any command registered with `name`
|
|
||||||
func (c *Commander) cderegister(L *lua.LState) int {
|
|
||||||
cmdName := L.CheckString(1)
|
cmdName := L.CheckString(1)
|
||||||
|
|
||||||
c.Events.Emit("commandDeregister", cmdName)
|
c.Events.Emit("commandDeregister", cmdName)
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// The fs module provides easy and simple access to filesystem functions and other
|
|
||||||
// things, and acts an addition to the Lua standard library's I/O and fs functions.
|
|
||||||
package fs
|
package fs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -7,7 +5,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"hilbish/util"
|
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"layeh.com/gopher-luar"
|
"layeh.com/gopher-luar"
|
||||||
)
|
)
|
||||||
|
@ -15,49 +12,42 @@ import (
|
||||||
func Loader(L *lua.LState) int {
|
func Loader(L *lua.LState) int {
|
||||||
mod := L.SetFuncs(L.NewTable(), exports)
|
mod := L.SetFuncs(L.NewTable(), exports)
|
||||||
|
|
||||||
util.Document(L, mod, `The fs module provides easy and simple access to filesystem functions and other
|
|
||||||
things, and acts an addition to the Lua standard library's I/O and fs functions.`)
|
|
||||||
|
|
||||||
L.Push(mod)
|
L.Push(mod)
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func luaErr(L *lua.LState, code int) {
|
func LuaErr(L *lua.LState, code int) {
|
||||||
// TODO: Error with a table, with path and error code
|
// TODO: Error with a table, with path and error code
|
||||||
L.Error(lua.LNumber(code), 2)
|
L.Error(lua.LNumber(code), 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
var exports = map[string]lua.LGFunction{
|
var exports = map[string]lua.LGFunction{
|
||||||
"cd": fcd,
|
"cd": cd,
|
||||||
"mkdir": fmkdir,
|
"mkdir": mkdir,
|
||||||
"stat": fstat,
|
"stat": stat,
|
||||||
}
|
}
|
||||||
|
|
||||||
// cd(dir)
|
func cd(L *lua.LState) int {
|
||||||
// Changes directory to `dir`
|
|
||||||
func fcd(L *lua.LState) int {
|
|
||||||
path := L.CheckString(1)
|
path := L.CheckString(1)
|
||||||
|
|
||||||
err := os.Chdir(strings.TrimSpace(path))
|
err := os.Chdir(strings.TrimSpace(path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
switch e := err.(*os.PathError).Err.Error(); e {
|
switch e := err.(*os.PathError).Err.Error(); e {
|
||||||
case "no such file or directory":
|
case "no such file or directory":
|
||||||
luaErr(L, 1)
|
LuaErr(L, 1)
|
||||||
case "not a directory":
|
case "not a directory":
|
||||||
luaErr(L, 2)
|
LuaErr(L, 2)
|
||||||
default:
|
default:
|
||||||
fmt.Printf("Found unhandled error case: %s\n", e)
|
fmt.Printf("Found unhandled error case: %s\n", e)
|
||||||
fmt.Printf("Report this at https://github.com/Rosettea/Hilbish/issues with the title being: \"fs: unhandled error case %s\", and show what caused it.\n", e)
|
fmt.Printf("Report this at https://github.com/Rosettea/Hilbish/issues with the title being: \"fs: unhandled error case %s\", and show what caused it.\n", e)
|
||||||
luaErr(L, 213)
|
LuaErr(L, 213)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// mkdir(name, recursive)
|
func mkdir(L *lua.LState) int {
|
||||||
// Makes a directory called `name`. If `recursive` is true, it will create its parent directories.
|
|
||||||
func fmkdir(L *lua.LState) int {
|
|
||||||
dirname := L.CheckString(1)
|
dirname := L.CheckString(1)
|
||||||
recursive := L.ToBool(2)
|
recursive := L.ToBool(2)
|
||||||
path := strings.TrimSpace(dirname)
|
path := strings.TrimSpace(dirname)
|
||||||
|
@ -72,9 +62,7 @@ func fmkdir(L *lua.LState) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// stat(path)
|
func stat(L *lua.LState) int {
|
||||||
// Returns info about `path`
|
|
||||||
func fstat(L *lua.LState) int {
|
|
||||||
path := L.CheckString(1)
|
path := L.CheckString(1)
|
||||||
|
|
||||||
// TODO: handle error here
|
// TODO: handle error here
|
||||||
|
|
33
hilbish.go
33
hilbish.go
|
@ -14,9 +14,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var exports = map[string]lua.LGFunction {
|
var exports = map[string]lua.LGFunction {
|
||||||
"run": hlrun,
|
"run": run,
|
||||||
"flag": hlflag,
|
"flag": flag,
|
||||||
"cwd": hlcwd,
|
"cwd": cwd,
|
||||||
}
|
}
|
||||||
|
|
||||||
func HilbishLoader(L *lua.LState) int {
|
func HilbishLoader(L *lua.LState) int {
|
||||||
|
@ -29,24 +29,23 @@ func HilbishLoader(L *lua.LState) int {
|
||||||
username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows
|
username = strings.Split(username, "\\")[1] // for some reason Username includes the hostname on windows
|
||||||
}
|
}
|
||||||
|
|
||||||
setField(L, mod, "ver", lua.LString(version), "The version of Hilbish")
|
L.SetField(mod, "ver", lua.LString(version))
|
||||||
setField(L, mod, "user", lua.LString(username), "Current user's username")
|
L.SetField(mod, "user", lua.LString(username))
|
||||||
setField(L, mod, "host", lua.LString(host), "Hostname of the system")
|
L.SetField(mod, "host", lua.LString(host))
|
||||||
setField(L, mod, "home", lua.LString(homedir), "Path of home directory")
|
L.SetField(mod, "home", lua.LString(homedir))
|
||||||
|
|
||||||
xdg := L.NewTable()
|
xdg := L.NewTable()
|
||||||
setField(L, xdg, "config", lua.LString(confDir), "XDG config directory")
|
L.SetField(xdg, "config", lua.LString(confDir))
|
||||||
setField(L, xdg, "data", lua.LString(getenv("XDG_DATA_HOME", homedir + "/.local/share/")), "XDG data directory")
|
L.SetField(xdg, "data", lua.LString(getenv("XDG_DATA_HOME", homedir + "/.local/share/")))
|
||||||
setField(L, mod, "xdg", xdg, "XDG values for Linux")
|
L.SetField(mod, "xdg", xdg)
|
||||||
|
|
||||||
L.Push(mod)
|
L.Push(mod)
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// run(cmd)
|
// Runs a command
|
||||||
// Runs `cmd` in Hilbish's sh interpreter
|
func run(L *lua.LState) int {
|
||||||
func hlrun(L *lua.LState) int {
|
|
||||||
var exitcode uint8 = 0
|
var exitcode uint8 = 0
|
||||||
cmd := L.CheckString(1)
|
cmd := L.CheckString(1)
|
||||||
err := execCommand(cmd)
|
err := execCommand(cmd)
|
||||||
|
@ -61,9 +60,7 @@ func hlrun(L *lua.LState) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// flag(f)
|
func flag(L *lua.LState) int {
|
||||||
// Checks if the `f` flag has been passed to Hilbish.
|
|
||||||
func hlflag(L *lua.LState) int {
|
|
||||||
flagchar := L.CheckString(1)
|
flagchar := L.CheckString(1)
|
||||||
|
|
||||||
L.Push(lua.LBool(getopt.Lookup([]rune(flagchar)[0]).Seen()))
|
L.Push(lua.LBool(getopt.Lookup([]rune(flagchar)[0]).Seen()))
|
||||||
|
@ -71,9 +68,7 @@ func hlflag(L *lua.LState) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// cwd()
|
func cwd(L *lua.LState) int {
|
||||||
// Returns the current directory of the shell
|
|
||||||
func hlcwd(L *lua.LState) int {
|
|
||||||
cwd, _ := os.Getwd()
|
cwd, _ := os.Getwd()
|
||||||
|
|
||||||
L.Push(lua.LString(cwd))
|
L.Push(lua.LString(cwd))
|
||||||
|
|
29
lua.go
29
lua.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hilbish/util"
|
|
||||||
"hilbish/golibs/bait"
|
"hilbish/golibs/bait"
|
||||||
"hilbish/golibs/commander"
|
"hilbish/golibs/commander"
|
||||||
"hilbish/golibs/fs"
|
"hilbish/golibs/fs"
|
||||||
|
@ -96,36 +95,18 @@ func RunLogin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setField(L *lua.LState, module lua.LValue, name string, val lua.LValue, doc string) {
|
|
||||||
if val.Type() == lua.LTTable {
|
|
||||||
util.Document(L, module, doc)
|
|
||||||
}
|
|
||||||
L.SetField(module, name, val)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* prompt(str)
|
|
||||||
Changes the shell prompt to `str`
|
|
||||||
There are a few verbs that can be used in the prompt text.
|
|
||||||
These will be formatted and replaced with the appropriate values.
|
|
||||||
`%d` - Current working directory
|
|
||||||
`%u` - Name of current user
|
|
||||||
`%h` - Hostname of device */
|
|
||||||
func hshprompt(L *lua.LState) int {
|
func hshprompt(L *lua.LState) int {
|
||||||
prompt = L.CheckString(1)
|
prompt = L.CheckString(1)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// multiprompt(str)
|
|
||||||
// Changes the continued line prompt to `str`
|
|
||||||
func hshmlprompt(L *lua.LState) int {
|
func hshmlprompt(L *lua.LState) int {
|
||||||
multilinePrompt = L.CheckString(1)
|
multilinePrompt = L.CheckString(1)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// alias(cmd, orig)
|
|
||||||
// Sets an alias of `orig` to `cmd`
|
|
||||||
func hshalias(L *lua.LState) int {
|
func hshalias(L *lua.LState) int {
|
||||||
alias := L.CheckString(1)
|
alias := L.CheckString(1)
|
||||||
source := L.CheckString(2)
|
source := L.CheckString(2)
|
||||||
|
@ -135,8 +116,6 @@ func hshalias(L *lua.LState) int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// appendPath(dir)
|
|
||||||
// Appends `dir` to $PATH
|
|
||||||
func hshappendPath(L *lua.LState) int {
|
func hshappendPath(L *lua.LState) int {
|
||||||
dir := L.CheckString(1)
|
dir := L.CheckString(1)
|
||||||
dir = strings.Replace(dir, "~", curuser.HomeDir, 1)
|
dir = strings.Replace(dir, "~", curuser.HomeDir, 1)
|
||||||
|
@ -150,8 +129,6 @@ func hshappendPath(L *lua.LState) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// exec(cmd)
|
|
||||||
// Replaces running hilbish with `cmd`
|
|
||||||
func hshexec(L *lua.LState) int {
|
func hshexec(L *lua.LState) int {
|
||||||
cmd := L.CheckString(1)
|
cmd := L.CheckString(1)
|
||||||
cmdArgs, _ := splitInput(cmd)
|
cmdArgs, _ := splitInput(cmd)
|
||||||
|
@ -169,22 +146,16 @@ func hshexec(L *lua.LState) int {
|
||||||
return 0 // random thought: does this ever return?
|
return 0 // random thought: does this ever return?
|
||||||
}
|
}
|
||||||
|
|
||||||
// goro(fn)
|
|
||||||
// Puts `fn` in a goroutine
|
|
||||||
func hshgoroutine(gofunc func()) {
|
func hshgoroutine(gofunc func()) {
|
||||||
go gofunc()
|
go gofunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
// timeout(cb, time)
|
|
||||||
// Runs the `cb` function after `time` in milliseconds
|
|
||||||
func hshtimeout(timeoutfunc func(), ms int) {
|
func hshtimeout(timeoutfunc func(), ms int) {
|
||||||
timeout := time.Duration(ms) * time.Millisecond
|
timeout := time.Duration(ms) * time.Millisecond
|
||||||
time.Sleep(timeout)
|
time.Sleep(timeout)
|
||||||
timeoutfunc()
|
timeoutfunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
// interval(cb, time)
|
|
||||||
// Runs the `cb` function every `time` milliseconds
|
|
||||||
func hshinterval(L *lua.LState) int {
|
func hshinterval(L *lua.LState) int {
|
||||||
intervalfunc := L.CheckFunction(1)
|
intervalfunc := L.CheckFunction(1)
|
||||||
ms := L.CheckInt(2)
|
ms := L.CheckInt(2)
|
||||||
|
|
3
rl.go
3
rl.go
|
@ -1,10 +1,9 @@
|
||||||
// +build !hilbiline
|
// +build !hilbiline
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// Here we define a generic interface for readline and hilbiline,
|
// Here we define a generic interface for readline and hilbiline,
|
||||||
// making them interchangable during build time
|
// making them interchangable during build time
|
||||||
// this is normal readline
|
// this is normal readline
|
||||||
|
package main
|
||||||
|
|
||||||
import "github.com/bobappleyard/readline"
|
import "github.com/bobappleyard/readline"
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
// +build hilbiline
|
// +build hilbiline
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// Here we define a generic interface for readline and hilbiline,
|
// Here we define a generic interface for readline and hilbiline,
|
||||||
// making them interchangable during build time
|
// making them interchangable during build time
|
||||||
// this is hilbiline's, as is obvious by the filename
|
// this is hilbiline's, as is obvious by the filename
|
||||||
|
package main
|
||||||
|
|
||||||
import "github.com/Rosettea/Hilbiline"
|
import "github.com/Rosettea/Hilbiline"
|
||||||
|
|
||||||
|
|
10
util/util.go
10
util/util.go
|
@ -1,10 +0,0 @@
|
||||||
package util
|
|
||||||
|
|
||||||
import "github.com/yuin/gopher-lua"
|
|
||||||
|
|
||||||
func Document(L *lua.LState, module lua.LValue, doc string) {
|
|
||||||
mt := L.NewTable()
|
|
||||||
L.SetField(mt, "__doc", lua.LString(doc))
|
|
||||||
|
|
||||||
L.SetMetatable(module, mt)
|
|
||||||
}
|
|
Loading…
Reference in New Issue