Allow mc-version-prefixed Forge version in init command

This commit is contained in:
comp500 2023-04-13 02:39:21 +01:00
parent 539be71d11
commit bfe570a6a2

View File

@ -9,6 +9,7 @@ import (
"github.com/packwiz/packwiz/core" "github.com/packwiz/packwiz/core"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"golang.org/x/exp/slices"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -100,18 +101,15 @@ var initCmd = &cobra.Command{
componentVersion = initReadValue(loader.FriendlyName+" version ["+latestVersion+"]: ", latestVersion) componentVersion = initReadValue(loader.FriendlyName+" version ["+latestVersion+"]: ", latestVersion)
} }
} }
found := false v := componentVersion
for _, v := range versions { if loader.Name == "forge" {
if componentVersion == v { v = cmdshared.GetRawForgeVersion(componentVersion)
found = true
break
}
} }
if !found { if !slices.Contains(versions, v) {
fmt.Println("Given " + loader.FriendlyName + " version cannot be found!") fmt.Println("Given " + loader.FriendlyName + " version cannot be found!")
os.Exit(1) os.Exit(1)
} }
modLoaderVersions[loader.Name] = componentVersion modLoaderVersions[loader.Name] = v
} else { } else {
fmt.Println("Given mod loader is not supported! Use \"none\" to specify no modloader, or to configure one manually.") fmt.Println("Given mod loader is not supported! Use \"none\" to specify no modloader, or to configure one manually.")
fmt.Print("The following mod loaders are supported: ") fmt.Print("The following mod loaders are supported: ")