better version
This commit is contained in:
3
Makefile
3
Makefile
@@ -9,7 +9,8 @@ MAIN_GO=$(CMD_DIR)/main.go
|
|||||||
# Version
|
# Version
|
||||||
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||||
BUILD_TIME=$(shell date +%FT%T%z)
|
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 variables
|
||||||
GO?=go
|
GO?=go
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -31,9 +32,28 @@ import (
|
|||||||
"github.com/sipeed/picoclaw/pkg/voice"
|
"github.com/sipeed/picoclaw/pkg/voice"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.1.0"
|
var (
|
||||||
|
version = "0.1.0"
|
||||||
|
buildTime string
|
||||||
|
goVersion string
|
||||||
|
)
|
||||||
|
|
||||||
const logo = "🦞"
|
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 {
|
func copyDirectory(src, dst string) error {
|
||||||
return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
return filepath.Walk(src, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -137,7 +157,7 @@ func main() {
|
|||||||
skillsHelp()
|
skillsHelp()
|
||||||
}
|
}
|
||||||
case "version", "--version", "-v":
|
case "version", "--version", "-v":
|
||||||
fmt.Printf("%s picoclaw v%s\n", logo, version)
|
printVersion()
|
||||||
default:
|
default:
|
||||||
fmt.Printf("Unknown command: %s\n", command)
|
fmt.Printf("Unknown command: %s\n", command)
|
||||||
printHelp()
|
printHelp()
|
||||||
|
|||||||
Reference in New Issue
Block a user