1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-07 15:06:47 +00:00

chore(cmd): added git hash and build date to version

这个提交包含在:
bigeagle
2016-06-15 14:26:32 +08:00
父节点 d292f9b0e3
当前提交 03fdaeeb7f
共有 6 个文件被更改,包括 77 次插入4 次删除

查看文件

@@ -1,8 +1,10 @@
package main
import (
"fmt"
"os"
"os/signal"
"strconv"
"syscall"
"time"
@@ -16,6 +18,11 @@ import (
"github.com/tuna/tunasync/worker"
)
var (
buildstamp = ""
githash = "No githash provided"
)
var logger = logging.MustGetLogger("tunasync")
func startManager(c *cli.Context) {
@@ -99,6 +106,28 @@ func startWorker(c *cli.Context) {
}
func main() {
cli.VersionPrinter = func(c *cli.Context) {
var builddate string
if buildstamp == "" {
builddate = "No build date provided"
} else {
ts, err := strconv.Atoi(buildstamp)
if err != nil {
builddate = "No build date provided"
} else {
t := time.Unix(int64(ts), 0)
builddate = t.String()
}
}
fmt.Printf(
"Version: %s\n"+
"Git Hash: %s\n"+
"Build Date: %s\n",
c.App.Version, githash, builddate,
)
}
app := cli.NewApp()
app.EnableBashCompletion = true
app.Version = "0.1"