Fixed everything rai did, probably broke something else
This commit is contained in:
parent
ff60e415b6
commit
0788aca862
@ -115,16 +115,12 @@ func SearchMods(inp string) fuzzy.Ranks {
|
|||||||
|
|
||||||
// GetModData gets object of mod by depString
|
// GetModData gets object of mod by depString
|
||||||
func GetModData(depString string) (int, Mod) {
|
func GetModData(depString string) (int, Mod) {
|
||||||
// ThinkInvis-Yeet
|
|
||||||
fmt.Printf("Getting data for: %s\n", depString)
|
|
||||||
fmt.Println([]byte(depString))
|
|
||||||
if depString == "R2API" {
|
if depString == "R2API" {
|
||||||
depString = "tristanmcpherson-R2API"
|
depString = "tristanmcpherson-R2API"
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < len(PkgList); i++ {
|
for i := 0; i < len(PkgList); i++ {
|
||||||
if PkgList[i].FullName == depString {
|
if PkgList[i].FullName == depString {
|
||||||
fmt.Println("Got mod data!")
|
|
||||||
return 0, PkgList[i]
|
return 0, PkgList[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
29
cli/cli.go
29
cli/cli.go
@ -3,18 +3,18 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"r2go/tools"
|
"r2go/tools"
|
||||||
|
"r2go/utils"
|
||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InstallMod is a CLI frontend for tools.DownloadMod.
|
// InstallMod is a CLI frontend for tools.DownloadMod.
|
||||||
func InstallMod(pkg string) []string {
|
func InstallMod(pkg string) {
|
||||||
green := color.New(color.FgGreen).SprintFunc()
|
green := color.New(color.FgGreen).SprintFunc()
|
||||||
magenta := color.New(color.FgMagenta).SprintFunc()
|
magenta := color.New(color.FgMagenta).SprintFunc()
|
||||||
red := color.New(color.FgRed).SprintFunc()
|
red := color.New(color.FgRed).SprintFunc()
|
||||||
blue := color.New(color.FgBlue).SprintFunc()
|
blue := color.New(color.FgBlue).SprintFunc()
|
||||||
cyan := color.New(color.FgCyan).SprintFunc()
|
cyan := color.New(color.FgCyan).SprintFunc()
|
||||||
// deps := []string{}
|
|
||||||
|
|
||||||
buffer := cyan(fmt.Sprint(" > ", tools.ExposeModString(pkg), "... "))
|
buffer := cyan(fmt.Sprint(" > ", tools.ExposeModString(pkg), "... "))
|
||||||
stat, ov, deps := tools.DownloadMod(tools.ExposeModString(pkg))
|
stat, ov, deps := tools.DownloadMod(tools.ExposeModString(pkg))
|
||||||
@ -29,24 +29,25 @@ func InstallMod(pkg string) []string {
|
|||||||
buffer += blue("downloaded")
|
buffer += blue("downloaded")
|
||||||
}
|
}
|
||||||
|
|
||||||
// if stat != 3 {
|
dependencies := []string{}
|
||||||
// _, mod := api.GetModData(tools.ExposeModString(pkg))
|
for _, d := range deps {
|
||||||
// for _, dep := range mod.Versions[0].Dependencies {
|
dependency := tools.ExposeModString(d)
|
||||||
// depString := tools.ExposeModString(dep)
|
if !utils.ExistsInArray(dependencies, d) {
|
||||||
// if depString != "tristanmcpherson-R2API" && depString != "bbepis-BepInExPack" {
|
if dependency != "bbepis-BepInExPack" && dependency != "tristanmcpherson-R2API" {
|
||||||
// deps = append(deps, depString)
|
dependencies = append(dependencies, d)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
fmt.Println(buffer)
|
fmt.Println(buffer)
|
||||||
return deps
|
fmt.Println("> Resolving dependencies...")
|
||||||
|
for _, d := range dependencies {
|
||||||
|
InstallMod(d)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveMod is a CLI frontend for tools.RemoveMod
|
// RemoveMod is a CLI frontend for tools.RemoveMod
|
||||||
func RemoveMod(pkg string) {
|
func RemoveMod(pkg string) {
|
||||||
// ThinkInvis-Yeet
|
|
||||||
// fmt.Println(pkg)
|
|
||||||
blue := color.New(color.FgBlue).SprintFunc()
|
blue := color.New(color.FgBlue).SprintFunc()
|
||||||
red := color.New(color.FgRed).SprintFunc()
|
red := color.New(color.FgRed).SprintFunc()
|
||||||
cyan := color.New(color.FgCyan).SprintFunc()
|
cyan := color.New(color.FgCyan).SprintFunc()
|
||||||
|
19
main.go
19
main.go
@ -18,7 +18,6 @@ var version string = "0.0.1"
|
|||||||
|
|
||||||
// Init starts the CLI frontend for r2go
|
// Init starts the CLI frontend for r2go
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
logFile, err := os.OpenFile(utils.SystemInfo.ProgDir+"/r2mod-go.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
|
logFile, err := os.OpenFile(utils.SystemInfo.ProgDir+"/r2mod-go.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
|
||||||
utils.CheckErr(err)
|
utils.CheckErr(err)
|
||||||
|
|
||||||
@ -71,24 +70,14 @@ func main() {
|
|||||||
api.CheckAPICache()
|
api.CheckAPICache()
|
||||||
api.InitAPI()
|
api.InitAPI()
|
||||||
fmt.Println("> Downloading mods...")
|
fmt.Println("> Downloading mods...")
|
||||||
dependencies := []string{}
|
|
||||||
for _, m := range os.Args[2:] {
|
for _, m := range os.Args[2:] {
|
||||||
newdeps := cli.InstallMod(m)
|
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
color.Green("> Complete!")
|
color.Green("> Complete!")
|
||||||
case "remove", "rm", "r":
|
case "remove", "rm", "r":
|
||||||
|
api.InitAPI()
|
||||||
fmt.Println("> Removing mods...")
|
fmt.Println("> Removing mods...")
|
||||||
for _, m := range os.Args[2:] {
|
for _, m := range os.Args[2:] {
|
||||||
cli.RemoveMod(m)
|
cli.RemoveMod(m)
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package tools
|
package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
@ -43,7 +42,6 @@ func DownloadMod(depString string) (int, string, []string) {
|
|||||||
modFolder := sysinfo.PluginDir + "/" + depString + "-" + modVersion
|
modFolder := sysinfo.PluginDir + "/" + depString + "-" + modVersion
|
||||||
|
|
||||||
if utils.PathExists(modFolder) {
|
if utils.PathExists(modFolder) {
|
||||||
|
|
||||||
return 1, modver, deps
|
return 1, modver, deps
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,23 +70,13 @@ func DownloadMod(depString string) (int, string, []string) {
|
|||||||
deps = append(deps, dep)
|
deps = append(deps, dep)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Dependencies!
|
|
||||||
// fmt.Println("pog")
|
|
||||||
// for _, dep := range mod.Versions[0].Dependencies {
|
|
||||||
// DownloadMod(dep)
|
|
||||||
// }
|
|
||||||
|
|
||||||
return status, modver, deps
|
return status, modver, deps
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveMod uninstalls a mod
|
// 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
|
// 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 {
|
func RemoveMod(depString string) int {
|
||||||
// ThinkInvis-Yeet
|
|
||||||
// fmt.Println(depString)
|
|
||||||
status, mod := api.GetModData(depString)
|
status, mod := api.GetModData(depString)
|
||||||
fmt.Println(status)
|
|
||||||
fmt.Println(mod)
|
|
||||||
if status != 0 {
|
if status != 0 {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user