mirror of https://github.com/Hilbis/Hilbish
Compare commits
3 Commits
52379dbdd7
...
062f40e9e5
Author | SHA1 | Date |
---|---|---|
TorchedSammy | 062f40e9e5 | |
TorchedSammy | 44e2a458f5 | |
TorchedSammy | 3b6284bc7c |
15
api.go
15
api.go
|
@ -30,6 +30,7 @@ var exports = map[string]lua.LGFunction {
|
|||
"read": hlread,
|
||||
"run": hlrun,
|
||||
"timeout": hltimeout,
|
||||
"which": hlwhich,
|
||||
}
|
||||
|
||||
var greeting string
|
||||
|
@ -331,3 +332,17 @@ func hlprependPath(L *lua.LState) int {
|
|||
|
||||
return 0
|
||||
}
|
||||
|
||||
// which(binName)
|
||||
// Searches for an executable called `binName` in the directories of $PATH
|
||||
func hlwhich(L *lua.LState) int {
|
||||
binName := L.CheckString(1)
|
||||
path, err := exec.LookPath(binName)
|
||||
if err != nil {
|
||||
l.Push(lua.LNil)
|
||||
return 1
|
||||
}
|
||||
|
||||
l.Push(lua.LString(path))
|
||||
return 1
|
||||
}
|
||||
|
|
|
@ -35,3 +35,5 @@ run(cmd) > Runs `cmd` in Hilbish's sh interpreter.
|
|||
|
||||
timeout(cb, time) > Runs the `cb` function after `time` in milliseconds
|
||||
|
||||
which(binName) > Searches for an executable called `binName` in the directories of $PATH
|
||||
|
||||
|
|
|
@ -65,4 +65,7 @@ function hilbish.run(cmd) end
|
|||
--- @param time number
|
||||
function hilbish.timeout(cb, time) end
|
||||
|
||||
--- Searches for an executable called `binName` in the directories of $PATH
|
||||
function hilbish.which() end
|
||||
|
||||
return hilbish
|
||||
|
|
Loading…
Reference in New Issue