Skip to content

Commit

Permalink
Add -version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjunwen committed Jun 14, 2019
1 parent 4e8a800 commit 897c579
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package main

import (
"flag"
"fmt"
"log"
"net/http"
"path"
"runtime/debug"
"strings"

"github.com/huangjunwen/sqlw-mysql/render"
Expand All @@ -30,6 +32,7 @@ var (
outputPkg string
whitelist commaSeperatd
blacklist commaSeperatd
version bool
)

func main() {
Expand All @@ -41,7 +44,19 @@ func main() {
flag.StringVar(&outputPkg, "pkg", "", "(Optional) Alternative package name of the generated code.")
flag.Var(&whitelist, "whitelist", "(Optional) Comma separated table names to render.")
flag.Var(&blacklist, "blacklist", "(Optional) Comma separated table names not to render.")
flag.BoolVar(&version, "version", false, "Show version information.")
flag.Parse()

if version {
info, ok := debug.ReadBuildInfo()
if !ok {
fmt.Println("sqlw-mysql unknown version")
} else {
fmt.Printf("sqlw-mysql version=%s sum=%s\n", info.Main.Version, info.Main.Sum)
}
return
}

if dsn == "" {
log.Fatalf("Missing -dsn")
}
Expand Down

0 comments on commit 897c579

Please sign in to comment.