Skip to content

Commit

Permalink
recenter
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanisham committed Mar 28, 2024
1 parent c657f57 commit 083c2ad
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
13 changes: 13 additions & 0 deletions cli/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cli

import "testing"

func TestValidateVMUalias(t *testing.T) {
if !validVmuAlis("mach") {
t.Errorf("mach: should be true")
}

if !validVmuAlis("default"){
t.Errorf("default: should be true")
}
}
28 changes: 5 additions & 23 deletions cli/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,18 @@ import (
)

func (z *ZVM) Use(ver string) error {
err := z.getVersion(ver)
if errors.Is(err, os.ErrNotExist) {
if err := z.getVersion(ver); err != nil {
if errors.Is(err, os.ErrNotExist) {

// We might want to add an option in settings to toggle these in case some
// version map uses "default" as a version name.
switch ver {
case "default":
if err = z.Settings.ResetVersionMap(); err != nil {
return err
}
case "mach":
if err := z.Settings.SetVersionMapUrl("https://machengine.org/zig/index.json"); err != nil {
log.Info("Run `-vmu default` to reset your version map.")
}
default:
fmt.Printf("It looks like %s isn't installed. Would you like to install it? [y/n]\n", ver)
if getConfirmation() {
err = z.Install(ver)
if err = z.Install(ver); err != nil {
return err
}
} else {
return fmt.Errorf("version %s is not installed", ver)
}
}

} else if errors.Is(err, ErrUnsupportedVersion) {
log.Debug("User entered VMU alias")

}

if err != nil {
return err
}

return z.setBin(ver)
Expand Down

0 comments on commit 083c2ad

Please sign in to comment.