feat: add version flag

This commit is contained in:
2026-04-03 09:50:20 +03:00
parent df0c9d7b7e
commit 61bc9fe49f
3 changed files with 11 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ import (
"github.com/spf13/cobra"
)
var Version string
func Execute() error {
configFile := resolveConfigFile()
cfg, commands, err := loadConfig(configFile)
@@ -22,6 +24,8 @@ func Execute() error {
}
rootCmd.PersistentFlags().String("wand-file", "", "path to wand config file (overrides discovery)")
rootCmd.Version = Version
rootCmd.SetVersionTemplate("{{.Version}}\n")
if main, ok := commands["main"]; ok {
rootCmd.Short = main.Description

View File

@@ -1,13 +1,19 @@
package main
import (
_ "embed"
"fmt"
"os"
"strings"
"github.com/chenasraf/wand/cmd"
)
//go:embed version.txt
var version string
func main() {
cmd.Version = strings.TrimSpace(version)
if err := cmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)

1
version.txt Normal file
View File

@@ -0,0 +1 @@
1.3.1