package cli import ( "fmt" "r2go/api" "r2go/tools" "github.com/fatih/color" ) // InstallMod is a CLI frontend for tools.DownloadMod. func InstallMod(pkg string) { buffer := fmt.Sprint(" > ", tools.ExposeModString(pkg), "... ") stat, ov := tools.DownloadMod(tools.ExposeModString(pkg)) green := color.New(color.FgGreen).SprintFunc() magenta := color.New(color.FgMagenta).SprintFunc() blue := color.New(color.FgBlue).SprintFunc() if stat == 1 { buffer += green("up to date!") } else if stat == 2 { buffer += fmt.Sprintf("%s %s", magenta("updating to version"), ov) } else { buffer += blue("downloaded") } mod := api.GetModData(tools.ExposeModString(pkg)) for _, dep := range mod.Versions[0].Dependencies { depString := tools.ExposeModString(dep) if depString != "tristanmcpherson-R2API" && depString != "bbepis-BepInExPack" { InstallMod(depString) } } fmt.Println(buffer) } // RemoveMod is a CLI frontend for tools.RemoveMod func RemoveMod(pkg string) { blue := color.New(color.FgBlue).SprintFunc() red := color.New(color.FgRed).SprintFunc() buffer := fmt.Sprint(" > ", tools.ExposeModString(pkg), "... ") if tools.RemoveMod(tools.ExposeModString(pkg)) == 1 { buffer += red("not installed") } else { buffer += blue("uninstalled") } fmt.Println(buffer) }