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 2c7e80c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion plugn.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,18 @@ 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)
}
Expand Down

0 comments on commit 2c7e80c

Please sign in to comment.