Skip to content

Commit

Permalink
feat: spec in version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Yakiyo committed Aug 23, 2023
1 parent 0045fcb commit 4987411
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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]")
Expand Down
8 changes: 8 additions & 0 deletions meta/meta.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package meta

var (
// app version
Version = "0.1.0"
// tldr specifications
TldrSpec = "1.5"
)

0 comments on commit 4987411

Please # to comment.