Add dependency list builder

This commit is contained in:
rainyuu 2021-01-31 11:07:37 +01:00
parent d6e0e19121
commit 4216fa4256
2 changed files with 13 additions and 3 deletions

View File

@ -9,12 +9,13 @@ import (
)
// InstallMod is a CLI frontend for tools.DownloadMod.
func InstallMod(pkg string) {
func InstallMod(pkg string) []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 := tools.DownloadMod(tools.ExposeModString(pkg))
@ -34,13 +35,14 @@ func InstallMod(pkg string) {
for _, dep := range mod.Versions[0].Dependencies {
depString := tools.ExposeModString(dep)
if depString != "tristanmcpherson-R2API" && depString != "bbepis-BepInExPack" {
InstallMod(depString)
deps = append(deps, depString)
}
}
}
fmt.Println(buffer)
return deps
}
// RemoveMod is a CLI frontend for tools.RemoveMod

10
main.go
View File

@ -71,8 +71,16 @@ func main() {
api.CheckAPICache()
api.InitAPI()
fmt.Println("> Downloading mods...")
dependencies := []string{}
for _, m := range os.Args[2:] {
cli.InstallMod(m)
newdeps := cli.InstallMod(m)
for _, d := range newdeps {
dependencies = append(dependencies, d)
}
}
fmt.Println("> Downloading dependencies...")
for _, d := range dependencies {
cli.InstallMod(d)
}
color.Green("> Complete!")
case "remove", "rm", "r":