mirror of https://github.com/Hilbis/Hilbish
Compare commits
No commits in common. "84ec3d085d1e7c77b5a22dff9bc4630d72968edf" and "54d88f9f6c230b4805d042be93e6c4aaa1e70582" have entirely different histories.
84ec3d085d
...
54d88f9f6c
|
@ -2,9 +2,5 @@ cwd() > Returns the current directory of the shell
|
||||||
|
|
||||||
flag(f) > Checks if the `f` flag has been passed to Hilbish.
|
flag(f) > Checks if the `f` flag has been passed to Hilbish.
|
||||||
|
|
||||||
read(prompt) -> input? > Read input from the user, using Hilbish's line editor/input reader.
|
|
||||||
This is a separate instance from the one Hilbish actually uses.
|
|
||||||
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
|
||||||
|
|
||||||
run(cmd) > Runs `cmd` in Hilbish's sh interpreter
|
run(cmd) > Runs `cmd` in Hilbish's sh interpreter
|
||||||
|
|
||||||
|
|
22
hilbish.go
22
hilbish.go
|
@ -19,7 +19,6 @@ var exports = map[string]lua.LGFunction {
|
||||||
"run": hlrun,
|
"run": hlrun,
|
||||||
"flag": hlflag,
|
"flag": hlflag,
|
||||||
"cwd": hlcwd,
|
"cwd": hlcwd,
|
||||||
"read": hlread,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HilbishLoader(L *lua.LState) int {
|
func HilbishLoader(L *lua.LState) int {
|
||||||
|
@ -37,8 +36,6 @@ func HilbishLoader(L *lua.LState) int {
|
||||||
L.SetField(mod, "host", lua.LString(host))
|
L.SetField(mod, "host", lua.LString(host))
|
||||||
L.SetField(mod, "home", lua.LString(homedir))
|
L.SetField(mod, "home", lua.LString(homedir))
|
||||||
L.SetField(mod, "dataDir", lua.LString(dataDir))
|
L.SetField(mod, "dataDir", lua.LString(dataDir))
|
||||||
L.SetField(mod, "interactive", lua.LBool(interactive))
|
|
||||||
L.SetField(mod, "login", lua.LBool(interactive))
|
|
||||||
|
|
||||||
xdg := L.NewTable()
|
xdg := L.NewTable()
|
||||||
L.SetField(xdg, "config", lua.LString(confDir))
|
L.SetField(xdg, "config", lua.LString(confDir))
|
||||||
|
@ -95,22 +92,3 @@ func getenv(key, fallback string) string {
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
// read(prompt) -> input?
|
|
||||||
// Read input from the user, using Hilbish's line editor/input reader.
|
|
||||||
// This is a separate instance from the one Hilbish actually uses.
|
|
||||||
// Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
|
|
||||||
func hlread(L *lua.LState) int {
|
|
||||||
luaprompt := L.CheckString(1)
|
|
||||||
lualr := NewLineReader(luaprompt)
|
|
||||||
|
|
||||||
input, err := lualr.Read()
|
|
||||||
if err != nil {
|
|
||||||
L.Push(lua.LNil)
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
L.Push(lua.LString(input))
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue