Skip to content

Commit

Permalink
Added formal version string
Browse files Browse the repository at this point in the history
Added --version support. The string it and `version` print has been moved to a var in cli/meta.
  • Loading branch information
tristanisham committed Mar 27, 2024
1 parent d575e4c commit 5a50aa1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
14 changes: 13 additions & 1 deletion cli/meta/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,17 @@
// license that can be found in the LICENSE file.
package meta

const VERSION = "v0.6.0"
import (
"fmt"
"runtime"
)

const (
VERSION = "v0.6.0"
)


var (
VerCopy = fmt.Sprintf("zvm %s %s/%s", VERSION, runtime.GOOS, runtime.GOARCH)
)

11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"fmt"
"html/template"
"os"
"runtime"
"strings"

"github.com/tristanisham/zvm/cli"
Expand All @@ -18,7 +17,6 @@ import (
"github.com/charmbracelet/log"

_ "embed"

)

//go:embed help.txt
Expand All @@ -38,7 +36,7 @@ func main() {
}

// zvm.AlertIfUpgradable()

versionFlag := flag.Bool("version", false, "Print ZVM version information")
// Install flags
installFlagSet := flag.NewFlagSet("install", flag.ExitOnError)
installDeps := installFlagSet.String("D", "", "Specify additional dependencies to install with Zig")
Expand All @@ -52,6 +50,11 @@ func main() {
sColorToggle := flag.Bool("color", true, "Turn on or off ZVM's color output")
flag.Parse()

if *versionFlag {
fmt.Println(meta.VerCopy)
os.Exit(0)
}

if sVersionMapUrl != nil && len(*sVersionMapUrl) != 0 {
log.Debug("user passed vmu", "url", *sVersionMapUrl)
switch *sVersionMapUrl {
Expand Down Expand Up @@ -173,7 +176,7 @@ func main() {
}

case "version":
fmt.Printf("zvm %s build %s/%s",meta.VERSION, runtime.GOOS, runtime.GOARCH)
fmt.Println(meta.VerCopy)
return
case "help":
//zvm.Settings.UseColor
Expand Down

0 comments on commit 5a50aa1

Please sign in to comment.