mirror of
https://github.com/chenasraf/wand.git
synced 2026-05-17 17:38:02 +00:00
feat: add version flag
This commit is contained in:
@@ -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
|
||||
|
||||
6
main.go
6
main.go
@@ -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
1
version.txt
Normal file
@@ -0,0 +1 @@
|
||||
1.3.1
|
||||
Reference in New Issue
Block a user