From 49874117efdbfce0fe1b3cfa63cc59af50965bbc Mon Sep 17 00:00:00 2001 From: Yakiyo Date: Wed, 23 Aug 2023 04:58:10 +0000 Subject: [PATCH] feat: spec in version flag --- cmd/root.go | 8 +++++++- meta/meta.go | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 meta/meta.go diff --git a/cmd/root.go b/cmd/root.go index a82b85d..a971061 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -7,6 +7,7 @@ import ( "github.com/Yakiyo/tilde/cache" "github.com/Yakiyo/tilde/config" + "github.com/Yakiyo/tilde/meta" "github.com/Yakiyo/tilde/utils" "github.com/Yakiyo/tilde/where" "github.com/charmbracelet/log" @@ -22,7 +23,7 @@ var rootCmd = &cobra.Command{ Long: `tilde is a fast and frictionless console client for tldr. View community driven and simplified man pages in your terminal`, - Version: "0.1.0", + Version: meta.Version, PreRunE: func(cmd *cobra.Command, args []string) error { config.BindFlags(cmd) return nil @@ -63,6 +64,11 @@ func Execute() { } func init() { + rootCmd.SetVersionTemplate(func() string { + return `{{with .Name}}{{printf "%s " .}}{{end}}{{printf "version %s" .Version}}` + + fmt.Sprintf("\ntldr spec version %v\n", meta.TldrSpec) + }()) + f := rootCmd.Flags() // config flags f.String("log-level", "warn", "Set log level [debug, info, warn, error]") diff --git a/meta/meta.go b/meta/meta.go new file mode 100644 index 0000000..a2ac312 --- /dev/null +++ b/meta/meta.go @@ -0,0 +1,8 @@ +package meta + +var ( + // app version + Version = "0.1.0" + // tldr specifications + TldrSpec = "1.5" +)