mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
Feature: add version command (#148)
This commit is contained in:
parent
a775ef0077
commit
e3c78f934e
10
Makefile
10
Makefile
|
@ -1,6 +1,10 @@
|
|||
NAME=clash
|
||||
BINDIR=bin
|
||||
GOBUILD=CGO_ENABLED=0 go build -ldflags '-w -s'
|
||||
VERSION=$(shell git describe --tags --long --dirty || echo "unkown version")
|
||||
BUILDTIME=$(shell date -u)
|
||||
GOBUILD=CGO_ENABLED=0 go build -ldflags '-X "github.com/Dreamacro/clash/constant.Version=$(VERSION)" \
|
||||
-X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" \
|
||||
-w -s'
|
||||
|
||||
PLATFORM_LIST = \
|
||||
darwin-amd64 \
|
||||
|
@ -77,10 +81,10 @@ zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST))
|
|||
|
||||
$(gz_releases): %.gz : %
|
||||
chmod +x $(BINDIR)/$(NAME)-$(basename $@)
|
||||
gzip -f $(BINDIR)/$(NAME)-$(basename $@)
|
||||
tar -czf $(BINDIR)/$(NAME)-$(basename $@)-$(VERSION).tar.gz -C $(BINDIR) $(NAME)-$(basename $@)
|
||||
|
||||
$(zip_releases): %.zip : %
|
||||
zip -m -j $(BINDIR)/$(NAME)-$(basename $@).zip $(BINDIR)/$(NAME)-$(basename $@).exe
|
||||
zip -m -j $(BINDIR)/$(NAME)-$(basename $@)-$(VERSION).zip $(BINDIR)/$(NAME)-$(basename $@).exe
|
||||
|
||||
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST)
|
||||
|
||||
|
|
6
constant/version.go
Normal file
6
constant/version.go
Normal file
|
@ -0,0 +1,6 @@
|
|||
package constant
|
||||
|
||||
var (
|
||||
Version = "unknown version"
|
||||
BuildTime = "unknown time"
|
||||
)
|
9
main.go
9
main.go
|
@ -2,9 +2,11 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"syscall"
|
||||
|
||||
"github.com/Dreamacro/clash/config"
|
||||
|
@ -15,15 +17,22 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
version bool
|
||||
homedir string
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&homedir, "d", "", "set configuration directory")
|
||||
flag.BoolVar(&version, "v", false, "show current version of clash")
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
func main() {
|
||||
if version {
|
||||
fmt.Printf("Clash %s %s %s %s\n", C.Version, runtime.GOOS, runtime.GOARCH, C.BuildTime)
|
||||
return
|
||||
}
|
||||
|
||||
// enable tls 1.3 and remove when go 1.13
|
||||
os.Setenv("GODEBUG", os.Getenv("GODEBUG")+",tls13=1")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user