From 1c33d63f590598c166ef0fcb4eb6554ca8bdee1c Mon Sep 17 00:00:00 2001 From: mozillazg Date: Tue, 15 May 2018 22:10:54 +0800 Subject: [PATCH 1/7] Remove unnecessary qiniupkg. Fixes #1 --- core/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/config.go b/core/config.go index fa048b6..1effd36 100644 --- a/core/config.go +++ b/core/config.go @@ -1,12 +1,12 @@ package core import ( + "errors" "fmt" "strings" "time" "github.com/samuel/go-zookeeper/zk" - "qiniupkg.com/x/errors.v7" ) type Config struct { From 034ae4c2d72005616bb8853a98bc568ec0c45bd3 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Tue, 15 May 2018 22:13:18 +0800 Subject: [PATCH 2/7] Update README. Fixes #3 --- Makefile | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 138867e..008a263 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ .PHONY: help help: @echo "lint run lint" - @echo "release-all compile for all platforms " + @echo "release-all compile for all platforms " PROJECT=zkcli VERSION=$(shell cat main.go |grep 'version = "[0-9]\+.[0-9]\+.[0-9]\+"' | awk -F '"' '{print $$2}') diff --git a/README.md b/README.md index 6e41a88..c6829c6 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ go install github.com/let-us-go/zkcli ### Build ``` -make release +make release-all ``` Or [download a pre-built binary](https://github.com/let-us-go/zkcli/releases) for Linux or macOS/OSX. From 4c5d6a4dc16d28deec01df6c873e69b27b985f61 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Tue, 15 May 2018 22:33:13 +0800 Subject: [PATCH 3/7] Close connection before exit. Closes #6 --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 04a03c4..0450ce9 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ func main() { fmt.Printf("%s\n", err) os.Exit(1) } + defer conn.Close() name, options := core.ParseCmd(strings.Join(args, " ")) cmd := core.NewCmd(name, options, conn, config) From add69127e15a855f934629ef437286d416122fc8 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Tue, 15 May 2018 22:55:47 +0800 Subject: [PATCH 4/7] Add -version to show version info --- Makefile | 6 +++++- main.go | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 008a263..1f61864 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,13 @@ help: PROJECT=zkcli VERSION=$(shell cat main.go |grep 'version = "[0-9]\+.[0-9]\+.[0-9]\+"' | awk -F '"' '{print $$2}') +GIT_COMMIT=$(shell git rev-parse --short HEAD) +BUILT_TIME=$(shell date -u '+%FT%T%z') GOVERSION=$(shell go version) GOOS=$(word 1,$(subst /, ,$(lastword $(GOVERSION)))) GOARCH=$(word 2,$(subst /, ,$(lastword $(GOVERSION)))) +LDFLAGS="-X main.gitCommit=${GIT_COMMIT} -X main.built=${BUILT_TIME}" ARCNAME=$(PROJECT)-$(VERSION)-$(GOOS)-$(GOARCH) RELDIR=$(ARCNAME) @@ -20,7 +23,7 @@ release: rm -rf $(DISTDIR)/$(RELDIR) mkdir -p $(DISTDIR)/$(RELDIR) go clean - GOOS=$(GOOS) GOARCH=$(GOARCH) go build + GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags ${LDFLAGS} cp $(PROJECT)$(SUFFIX_EXE) $(DISTDIR)/$(RELDIR)/ tar czf $(DISTDIR)/$(ARCNAME).tar.gz -C $(DISTDIR) $(RELDIR) go clean @@ -35,4 +38,5 @@ release-all: lint: gofmt -s -w . golint . + golint core go vet diff --git a/main.go b/main.go index 0450ce9..b21b6be 100644 --- a/main.go +++ b/main.go @@ -10,15 +10,25 @@ import ( "github.com/let-us-go/zkcli/core" ) +var gitCommit = "unknown" +var built = "unknown" + const version = "0.1.0" func main() { servers := flag.String("s", "127.0.0.1:2181", "Servers") username := flag.String("u", "", "Username") password := flag.String("p", "", "Password") + showVersion := flag.Bool("version", false, "Show version info") flag.Parse() args := flag.Args() + if *showVersion { + fmt.Printf("Version:\t%s\nGit commit:\t%s\nBuilt: %s\n", + version, gitCommit, built) + os.Exit(0) + } + config := core.NewConfig(strings.Split(*servers, ",")) if *username != "" && *password != "" { auth := core.NewAuth( From 4ed72fcded50427beb6a0cfcf1974d53ab4be2ef Mon Sep 17 00:00:00 2001 From: Qifei Wan Date: Wed, 30 May 2018 18:27:32 +0800 Subject: [PATCH 5/7] Ignored with the suffix slash of zpath when completion --- core/completer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/completer.go b/core/completer.go index aff51a8..022f335 100644 --- a/core/completer.go +++ b/core/completer.go @@ -40,7 +40,7 @@ func argumentsCompleter(args []string, cmd *Cmd) []prompt.Suggest { first := args[0] switch first { case "get", "ls", "create", "set", "delete": - p := args[1] + p := strings.TrimSuffix(args[1], "/") if len(args) > 2 { switch first { case "create", "set": From 9fd746b5834f1e0e62ae39ea1b44122168d783d2 Mon Sep 17 00:00:00 2001 From: mozillazg Date: Sat, 26 May 2018 12:54:49 +0800 Subject: [PATCH 6/7] test go1.10 --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4a82855..761d74d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,10 @@ language: go go: - 1.8 - 1.9 + - '1.10' sudo: false install: - - go get . + - go build + - ./zkcli -version From ac12eb2c931df6e7834242f4518ab6dbdb00b98a Mon Sep 17 00:00:00 2001 From: mozillazg Date: Wed, 30 May 2018 21:58:12 +0800 Subject: [PATCH 7/7] v0.2.0 --- CHANGELOG.md | 24 ++++++++++++++++++++++++ main.go | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58560e4..0f371d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,29 @@ # Changelog + +## [0.2.0] (2018-05-30) + +### New Features + +* Add `-version` to show version info ([add69127e](https://github.com/let-us-go/zkcli/commit/add69127e15a855f934629ef437286d416122fc8)) + +``` +$ zkcli -version +Version: 0.2.0 +Git commit: 9fd746b +Built: 2018-05-30T13:44:21+0000 +``` + +### Internal changes + +* Remove unnecessary qiniupkg ([1c33d63f590](https://github.com/let-us-go/zkcli/commit/1c33d63f590598c166ef0fcb4eb6554ca8bdee1c)) +* Close connection before exit ([4c5d6a4d](https://github.com/let-us-go/zkcli/commit/4c5d6a4dc16d28deec01df6c873e69b27b985f61)) +* Ignored with the suffix slash of zpath when completion ([#7](https://github.com/let-us-go/zkcli/pull/7)) + + ## 0.1.0 (2017-12-23) * Initial Release + + +[0.2.0]: https://github.com/let-us-go/zkcli/compare/v0.1.0...v0.2.0 diff --git a/main.go b/main.go index b21b6be..784652c 100644 --- a/main.go +++ b/main.go @@ -13,7 +13,7 @@ import ( var gitCommit = "unknown" var built = "unknown" -const version = "0.1.0" +const version = "0.2.0" func main() { servers := flag.String("s", "127.0.0.1:2181", "Servers")