From 6a456349d9816c4cd8a2e1430c016272680809ea Mon Sep 17 00:00:00 2001 From: Antoine Aflalo <197810+Belphemur@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:43:13 -0400 Subject: [PATCH] feat: add version command --- cmd/version_command.go | 21 +++++++++++++++++++++ meta/version.go | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 cmd/version_command.go create mode 100644 meta/version.go diff --git a/cmd/version_command.go b/cmd/version_command.go new file mode 100644 index 0000000..fe71ccf --- /dev/null +++ b/cmd/version_command.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "fmt" + "github.com/belphemur/CBZOptimizer/meta" + "github.com/spf13/cobra" +) + +func init() { + command := &cobra.Command{ + Use: "version", + Short: "Print the version of the application", + Long: "Print the version of the application", + Run: VersionCommand, + } + AddCommand(command) +} + +func VersionCommand(_ *cobra.Command, _ []string) { + fmt.Printf("CBZOptimizer %s [%s] built [%s]\n", meta.Version, meta.Commit, meta.Date) +} diff --git a/meta/version.go b/meta/version.go new file mode 100644 index 0000000..2f37bd7 --- /dev/null +++ b/meta/version.go @@ -0,0 +1,5 @@ +package meta + +var Version = "v0.0.0" +var Commit = "" +var Date = ""