From 2c7e80c25519d451f4f87b683eaec5e0d357d0be Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 29 Jun 2024 01:48:16 -0400 Subject: [PATCH] feat: add support for version flags --- plugn.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugn.go b/plugn.go index 650f95b..780e605 100644 --- a/plugn.go +++ b/plugn.go @@ -82,6 +82,10 @@ func isArg(argument string) bool { return len(os.Args) > 1 && os.Args[1] == argument } +func isVersionArg() bool { + return isArg("version") || isArg("--version") || isArg("-v") +} + func main() { os.Setenv("PLUGN_VERSION", Version) if data, err := os.ReadFile(".plugn"); err == nil { @@ -89,7 +93,7 @@ func main() { os.Setenv("PLUGIN_PATH", path) } } - if !isArg("version") && os.Getenv("PLUGIN_PATH") == "" { + if !isVersionArg() && os.Getenv("PLUGIN_PATH") == "" { fmt.Println("!! PLUGIN_PATH is not set in environment") os.Exit(2) }