better version

This commit is contained in:
li
2026-02-12 08:14:49 +08:00
parent 6ccd9d0a99
commit 8ceef6e8a7
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"
@@ -31,9 +32,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 {
@@ -137,7 +157,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()
@@ -771,7 +791,7 @@ func cronHelp() {
func cronListCmd(storePath string) {
cs := cron.NewCronService(storePath, nil)
jobs := cs.ListJobs(true) // Show all jobs, including disabled
jobs := cs.ListJobs(true) // Show all jobs, including disabled
if len(jobs) == 0 {
fmt.Println("No scheduled jobs.")