Skip to content

Commit

Permalink
bin: add flag to print version information (pingcap#1896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Librazy authored and hanfei1991 committed Oct 29, 2016
1 parent 0510f5c commit 96a444a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
)

var (
version = flag.Bool("v", false, "print version information and exit")
store = flag.String("store", "goleveldb", "registered store name, [memory, goleveldb, boltdb, tikv]")
storePath = flag.String("path", "/tmp/tidb", "tidb storage path")
logLevel = flag.String("L", "info", "log level: info, debug, warn, error, fatal")
Expand All @@ -69,6 +70,10 @@ func main() {
runtime.GOMAXPROCS(runtime.NumCPU())

flag.Parse()
if *version {
printer.PrintRawTiDBInfo()
os.Exit(0)
}

leaseDuration := parseLease()
tidb.SetSchemaLease(leaseDuration)
Expand Down
7 changes: 7 additions & 0 deletions util/printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package printer

import (
"bytes"
"fmt"

"github.com/ngaut/log"
)
Expand All @@ -33,6 +34,12 @@ func PrintTiDBInfo() {
log.Infof("UTC Build Time: %s", TiDBBuildTS)
}

// PrintRawTiDBInfo prints the TiDB version information without log info.
func PrintRawTiDBInfo() {
fmt.Println("Git Commit Hash:", TiDBGitHash)
fmt.Println("UTC Build Time: ", TiDBBuildTS)
}

// checkValidity checks whether cols and every data have the same length.
func checkValidity(cols []string, datas [][]string) bool {
colLen := len(cols)
Expand Down

0 comments on commit 96a444a

Please sign in to comment.