From c55e389220a3ba8d5721e48c57d1578315a6c896 Mon Sep 17 00:00:00 2001 From: moyiz <8603313+moyiz@users.noreply.github.com> Date: Tue, 19 Dec 2023 23:24:46 +0200 Subject: [PATCH] feat: add version flag --- .goreleaser.yaml | 2 ++ cmd/root.go | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 511a73c..428d04c 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -10,6 +10,8 @@ before: builds: - env: - CGO_ENABLED=0 + ldflags: + - -X github.com/moyiz/na/cmd.Version={{.Version}} goos: - linux - darwin diff --git a/cmd/root.go b/cmd/root.go index 60931a3..938dd47 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -11,11 +11,14 @@ import ( "github.com/spf13/cobra" ) +var Version string + var rootCmd = &cobra.Command{ - Use: "na", - Short: "CLI tool to effortlessly manage context aware nested shortcuts for shell commands.", - Long: consts.Logo, - Run: listRun, + Use: "na", + Short: "CLI tool to effortlessly manage context aware nested shortcuts for shell commands.", + Long: consts.Logo, + Run: listRun, + Version: Version, } func getConfigFromArgs() (string, error) {