Skip to content

Commit

Permalink
feat: add support for version flags
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Jun 29, 2024
1 parent c33a88b commit 9f8bc6c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion plugn.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,25 @@ 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 {
if path, err := filepath.Abs(string(data)); err == nil {
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)
}
if isVersionArg() {
os.Args[1] = "version"
}

PluginPath = os.Getenv("PLUGIN_PATH")
if isArg("gateway") {
runGateway()
Expand Down

0 comments on commit 9f8bc6c

Please sign in to comment.