mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "3c4351a8fe25de0683bc6c3b6216071ea027aac9" and "34a652c8bd10e4f30dee5e479af6f2b27a78c3c4" have entirely different histories.
3c4351a8fe
...
34a652c8bd
|
@ -2,4 +2,3 @@
|
||||||
hilbish
|
hilbish
|
||||||
|
|
||||||
.vim
|
.vim
|
||||||
petals/
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"layeh.com/gopher-luar"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Loader(L *lua.LState) int {
|
func Loader(L *lua.LState) int {
|
||||||
|
@ -23,8 +22,6 @@ func LuaErr(L *lua.LState, code int) {
|
||||||
|
|
||||||
var exports = map[string]lua.LGFunction{
|
var exports = map[string]lua.LGFunction{
|
||||||
"cd": cd,
|
"cd": cd,
|
||||||
"mkdir": mkdir,
|
|
||||||
"stat": stat,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cd(L *lua.LState) int {
|
func cd(L *lua.LState) int {
|
||||||
|
@ -41,21 +38,3 @@ func cd(L *lua.LState) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func mkdir(L *lua.LState) int {
|
|
||||||
dirname := L.ToString(1)
|
|
||||||
|
|
||||||
// TODO: handle error here
|
|
||||||
os.Mkdir(strings.TrimSpace(dirname), 0744)
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func stat(L *lua.LState) int {
|
|
||||||
path := L.ToString(1)
|
|
||||||
|
|
||||||
// TODO: handle error here
|
|
||||||
pathinfo, _ := os.Stat(path)
|
|
||||||
L.Push(luar.New(L, pathinfo))
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
7
lua.go
7
lua.go
|
@ -49,12 +49,7 @@ func LuaInit(confpath string) {
|
||||||
l.PreloadModule("bait", bait.Loader)
|
l.PreloadModule("bait", bait.Loader)
|
||||||
|
|
||||||
// Add more paths that Lua can require from
|
// Add more paths that Lua can require from
|
||||||
l.DoString(`package.path = package.path
|
l.DoString("package.path = package.path .. ';./libs/?/init.lua;/usr/share/hilbish/libs/?/init.lua'")
|
||||||
.. ';./libs/?/init.lua;./?/init.lua;./?/?.lua'
|
|
||||||
.. ';/usr/share/hilbish/libs/?/init.lua;'
|
|
||||||
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/init.lua;'
|
|
||||||
.. os.getenv 'HOME' .. '/.local/share/hilbish/libs/?/?.lua'
|
|
||||||
`)
|
|
||||||
|
|
||||||
err := l.DoFile("/usr/share/hilbish/preload.lua")
|
err := l.DoFile("/usr/share/hilbish/preload.lua")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue