From 12828d197abd967d3b8b1074dab3a533ae0666d1 Mon Sep 17 00:00:00 2001 From: sammyette <38820196+TorchedSammy@users.noreply.github.com> Date: Sun, 16 May 2021 18:10:46 -0400 Subject: [PATCH] feat: add hilbish.flag function this checks if a certain flag has been passed to hilbish --- hilbish.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hilbish.go b/hilbish.go index 5125621..1b92085 100644 --- a/hilbish.go +++ b/hilbish.go @@ -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 +}