Skip to content

Commit

Permalink
Add version information and flag
Browse files Browse the repository at this point in the history
  • Loading branch information
daenney committed Mar 12, 2024
1 parent c7c6c43 commit 2470f4f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,30 @@ import (
"github.com/expr-lang/expr"
)

var (
version = "unknown"
commit = "unknown"
date = "unknown"
)

func main() {
scripts := flag.String("scripts-dir", "", "path to load .expr scripts from")
showVersion := flag.Bool("version", false, "print version and exit")
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n\n", os.Args[0])
fmt.Fprintf(flag.CommandLine.Output(), "Parameters:\n\n")
flag.PrintDefaults()
fmt.Fprintf(flag.CommandLine.Output(), "\n")
fmt.Fprintf(flag.CommandLine.Output(), "Version: %s, Commit: %s, Date: %s\n", version, commit, date)
fmt.Fprintf(flag.CommandLine.Output(), "\n")
}
flag.Parse()

if *showVersion {
fmt.Fprintf(os.Stdout, "Version: %s, Commit: %s, Date: %s\n", version, commit, date)
os.Exit(0)
}

if *scripts == "" {
fmt.Println("please provide a directory to load scripts from")
os.Exit(1)
Expand Down

0 comments on commit 2470f4f

Please sign in to comment.