package cmd import ( "fmt" "os" "strings" "git.apinb.com/bsm-sdk/engine/vars" ) func NewCmd() { if len(os.Args) > 1 { parseArgs(os.Args[1]) } } func parseArgs(cmd string) { cmd = strings.ToLower(cmd) switch cmd { case "-v", "--v", "-version", "--version": versionCmd() case "--json": versionCmdJson() } os.Exit(0) } func versionCmd() { fmt.Printf("[Blocks Service: %s] Version: %s \n", vars.ServiceKey, vars.VERSION) fmt.Printf("[Blocks Service: %s] Compile: %s by %s build.\n", vars.ServiceKey, vars.GO_VERSION, vars.BUILD_TIME) } func versionCmdJson() { fmt.Printf("{\"version\":\"%s\",\"build_time\":\"%s\"}\n", vars.VERSION, vars.BUILD_TIME) }