Merge pull request #45 from jadeydi/main

better version info
This commit is contained in:
yinwm
2026-02-12 12:07:42 +08:00
committed by GitHub
2 changed files with 25 additions and 4 deletions

View File

@@ -9,7 +9,8 @@ MAIN_GO=$(CMD_DIR)/main.go
# Version
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date +%FT%T%z)
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME)"
GO_VERSION=$(shell $(GO) version | awk '{print $$3}')
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME) -X main.goVersion=$(GO_VERSION)"
# Go variables
GO?=go

View File

@@ -14,6 +14,7 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strings"
"time"
@@ -33,9 +34,28 @@ import (
"github.com/sipeed/picoclaw/pkg/voice"
)
const version = "0.1.0"
var (
version = "0.1.0"
buildTime string
goVersion string
)
const logo = "🦞"
func printVersion() {
fmt.Printf("%s picoclaw v%s\n", logo, version)
if buildTime != "" {
fmt.Printf(" Build: %s\n", buildTime)
}
goVer := goVersion
if goVer == "" {
goVer = runtime.Version()
}
if goVer != "" {
fmt.Printf(" Go: %s\n", goVer)
}
}
func copyDirectory(src, dst string) error {
return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
if err != nil {
@@ -143,7 +163,7 @@ func main() {
skillsHelp()
}
case "version", "--version", "-v":
fmt.Printf("%s picoclaw v%s\n", logo, version)
printVersion()
default:
fmt.Printf("Unknown command: %s\n", command)
printHelp()