Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin: add flag to print version information #1896

Merged
merged 1 commit into from
Oct 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bin: add flag to print version information
  • Loading branch information
Librazy committed Oct 28, 2016
commit eb362291ae1d24e7fcea701890430fc4991d9af1
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