feat: add hilbish.flag function

this checks if a certain flag has been passed to hilbish
pull/59/head
sammyette 2021-05-16 18:10:46 -04:00
parent 4b2891b503
commit 12828d197a
No known key found for this signature in database
GPG Key ID: 50EE40A2809851F5
1 changed files with 9 additions and 0 deletions

View File

@ -6,12 +6,14 @@ package main
import (
"os"
"github.com/pborman/getopt"
"github.com/yuin/gopher-lua"
"mvdan.cc/sh/v3/interp"
)
var exports = map[string]lua.LGFunction {
"run": run,
"flag": flag,
}
func HilbishLoader(L *lua.LState) int {
@ -44,3 +46,10 @@ func run(L *lua.LState) int {
return 1
}
func flag(L *lua.LState) int {
flagchar := L.CheckString(1)
L.Push(lua.LBool(getopt.Lookup([]rune(flagchar)[0]).Seen()))
return 1
}