Skip to content

Commit

Permalink
Merge pull request #172 from dokku/long-form-flags
Browse files Browse the repository at this point in the history
feat: add support for version flags
  • Loading branch information
josegonzalez authored Jun 29, 2024
2 parents c33a88b + 9f8bc6c commit 3406be2
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 3406be2

Please sign in to comment.