From 1ca3aafb9f50b4a1a7e41fc7e5c7a670d2905fd4 Mon Sep 17 00:00:00 2001 From: Lukas Malkmus Date: Sun, 8 Aug 2021 18:12:05 +0200 Subject: [PATCH] More grooming --- .goreleaser.yml | 2 +- Makefile | 4 ++-- cmd/horcrux/main.go | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 24393df..32ac502 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -135,7 +135,7 @@ brews: install: | bin.install "{{ .ProjectName }}" test: | - assert_match "Horcrux version #{version}", shell_output("#{bin}/{{ .ProjectName }} -v") + assert_match "horcrux version #{version}", shell_output("#{bin}/{{ .ProjectName }} -v") dockers: - ids: diff --git a/Makefile b/Makefile index 6c2d3b9..2ceef0f 100644 --- a/Makefile +++ b/Makefile @@ -117,9 +117,9 @@ $(COVERPROFILE): # INSTALL TARGETS -$(GOPATH)/bin/horcrux: dep.stamp $(call go-pkg-sourcefiles, ./...) +$(GOPATH)/bin/horcrux: dep.stamp $(call go-pkg-sourcefiles, ./cmd/horcrux) @echo ">> installing horcrux binary" - @$(GO_BIN_IN_PATH) install $(GOFLAGS) ./cmd/horcrux + @$(GO_BIN_IN_PATH) install $(GO_FLAGS) ./cmd/horcrux # TOOLS diff --git a/cmd/horcrux/main.go b/cmd/horcrux/main.go index 4139637..de72044 100644 --- a/cmd/horcrux/main.go +++ b/cmd/horcrux/main.go @@ -6,6 +6,7 @@ import ( "os" "strings" + "github.com/axiomhq/pkg/version" "github.com/golang/snappy" "github.com/manifoldco/promptui" "github.com/spf13/cobra" @@ -26,6 +27,9 @@ utility. Yes, the name is inspired by Harry Potter. func main() { rootCmd.SilenceUsage = true + rootCmd.Flags().BoolP("version", "v", false, "Show horcrux version") + rootCmd.SetVersionTemplate("{{ .Use }} version {{ .Version }}\n") + rootCmd.Version = version.Release() if err := rootCmd.Execute(); err != nil { os.Exit(1)