Fixed everything rai did, probably broke something else

This commit is contained in:
endigma 2021-01-31 12:47:05 -04:00
parent ff60e415b6
commit 0788aca862
4 changed files with 19 additions and 45 deletions

View File

@ -115,16 +115,12 @@ func SearchMods(inp string) fuzzy.Ranks {
// GetModData gets object of mod by depString
func GetModData(depString string) (int, Mod) {
// ThinkInvis-Yeet
fmt.Printf("Getting data for: %s\n", depString)
fmt.Println([]byte(depString))
if depString == "R2API" {
depString = "tristanmcpherson-R2API"
}
for i := 0; i < len(PkgList); i++ {
if PkgList[i].FullName == depString {
fmt.Println("Got mod data!")
return 0, PkgList[i]
}
}

View File

@ -3,18 +3,18 @@ package cli
import (
"fmt"
"r2go/tools"
"r2go/utils"
"github.com/fatih/color"
)
// InstallMod is a CLI frontend for tools.DownloadMod.
func InstallMod(pkg string) []string {
func InstallMod(pkg string) {
green := color.New(color.FgGreen).SprintFunc()
magenta := color.New(color.FgMagenta).SprintFunc()
red := color.New(color.FgRed).SprintFunc()
blue := color.New(color.FgBlue).SprintFunc()
cyan := color.New(color.FgCyan).SprintFunc()
// deps := []string{}
buffer := cyan(fmt.Sprint(" > ", tools.ExposeModString(pkg), "... "))
stat, ov, deps := tools.DownloadMod(tools.ExposeModString(pkg))
@ -29,24 +29,25 @@ func InstallMod(pkg string) []string {
buffer += blue("downloaded")
}
// if stat != 3 {
// _, mod := api.GetModData(tools.ExposeModString(pkg))
// for _, dep := range mod.Versions[0].Dependencies {
// depString := tools.ExposeModString(dep)
// if depString != "tristanmcpherson-R2API" && depString != "bbepis-BepInExPack" {
// deps = append(deps, depString)
// }
// }
// }
dependencies := []string{}
for _, d := range deps {
dependency := tools.ExposeModString(d)
if !utils.ExistsInArray(dependencies, d) {
if dependency != "bbepis-BepInExPack" && dependency != "tristanmcpherson-R2API" {
dependencies = append(dependencies, d)
}
}
}
fmt.Println(buffer)
return deps
fmt.Println("> Resolving dependencies...")
for _, d := range dependencies {
InstallMod(d)
}
}
// RemoveMod is a CLI frontend for tools.RemoveMod
func RemoveMod(pkg string) {
// ThinkInvis-Yeet
// fmt.Println(pkg)
blue := color.New(color.FgBlue).SprintFunc()
red := color.New(color.FgRed).SprintFunc()
cyan := color.New(color.FgCyan).SprintFunc()

19
main.go
View File

@ -18,7 +18,6 @@ var version string = "0.0.1"
// Init starts the CLI frontend for r2go
func main() {
logFile, err := os.OpenFile(utils.SystemInfo.ProgDir+"/r2mod-go.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
utils.CheckErr(err)
@ -71,24 +70,14 @@ func main() {
api.CheckAPICache()
api.InitAPI()
fmt.Println("> Downloading mods...")
dependencies := []string{}
for _, m := range os.Args[2:] {
newdeps := cli.InstallMod(m)
for _, d := range newdeps {
dependency := tools.ExposeModString(d)
if !utils.ExistsInArray(dependencies, d) {
if dependency != "bbepis-BepInExPack" && dependency != "tristanmcpherson-R2API" {
dependencies = append(dependencies, d)
}
}
}
}
fmt.Println("> Resolving dependencies...")
for _, d := range dependencies {
cli.InstallMod(d)
cli.InstallMod(m)
}
color.Green("> Complete!")
case "remove", "rm", "r":
api.InitAPI()
fmt.Println("> Removing mods...")
for _, m := range os.Args[2:] {
cli.RemoveMod(m)

View File

@ -1,7 +1,6 @@
package tools
import (
"fmt"
"io/ioutil"
"log"
"os"
@ -43,7 +42,6 @@ func DownloadMod(depString string) (int, string, []string) {
modFolder := sysinfo.PluginDir + "/" + depString + "-" + modVersion
if utils.PathExists(modFolder) {
return 1, modver, deps
}
@ -72,23 +70,13 @@ func DownloadMod(depString string) (int, string, []string) {
deps = append(deps, dep)
}
// TODO: Dependencies!
// fmt.Println("pog")
// for _, dep := range mod.Versions[0].Dependencies {
// DownloadMod(dep)
// }
return status, modver, deps
}
// RemoveMod uninstalls a mod
// RemoveMod returns 2 if the mod string was not found, 1 if the mod isn't installed and 0 on success
func RemoveMod(depString string) int {
// ThinkInvis-Yeet
// fmt.Println(depString)
status, mod := api.GetModData(depString)
fmt.Println(status)
fmt.Println(mod)
if status != 0 {
return 2
}