feat: add version flag

This commit is contained in:
2026-01-29 14:21:21 +02:00
parent 45bd05c07d
commit d913ae80f9
3 changed files with 15 additions and 1 deletions

View File

@@ -10,6 +10,9 @@ import (
)
var (
// Version is set by main.go from embedded version.txt
Version string
// Global flags
verbose bool
dry bool
@@ -66,6 +69,7 @@ func initConfig(cmd *cobra.Command, args []string) error {
// Execute adds all child commands to the root command and sets flags appropriately
func Execute() {
rootCmd.Version = Version
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, "Error:", err.Error())
os.Exit(1)

11
main.go
View File

@@ -1,7 +1,16 @@
package main
import "github.com/chenasraf/tx/internal/cli"
import (
_ "embed"
"strings"
"github.com/chenasraf/tx/internal/cli"
)
//go:embed version.txt
var version string
func main() {
cli.Version = strings.TrimSpace(version)
cli.Execute()
}

1
version.txt Normal file
View File

@@ -0,0 +1 @@
1.0.1