Gracefully exit on info with no 2nd parameter

This commit is contained in:
endigma 2021-01-27 19:41:55 -04:00
parent 9b83d7beea
commit 584c6cd90e
2 changed files with 13 additions and 7 deletions

View File

@ -44,6 +44,7 @@ type Version struct {
}
// CheckAPICache checks if the cached json is expired
// TODO: REWRITE
func CheckAPICache() {
// TODO: move the printing out, add returns
@ -70,6 +71,7 @@ func CheckAPICache() {
}
// UpdateAPICache gets a new copy of the thunderstore pkgfile
// TODO: ARIA2 IMPLEMENTATION
func UpdateAPICache() {
apiURL := "https://thunderstore.io/api/v1/package/"

18
main.go
View File

@ -42,16 +42,20 @@ func main() {
> remove, rem, r -- remove mod(s)
> list, ls, li -- list mods
> update, upgrade, up -- update mods and API cache
> toggle, tg, togglemods -- toggle mods
> toggle, tm, togglemods -- toggle mods
> filter -- remove version numbers using regex from stdin
`)
case "info":
var selectedmod api.Mod = api.GetModData(os.Args[2])
color.Cyan("Mod Info: %s", os.Args[2])
fmt.Println(" Name: " + selectedmod.Versions[0].FullName)
fmt.Println(" Desc: " + selectedmod.Versions[0].Description)
fmt.Println(" Version: " + selectedmod.Versions[0].VersionNumber)
fmt.Println(" Download URL: " + selectedmod.Versions[0].DownloadURL)
if len(os.Args) <= 2 {
fmt.Println("Usage: r2mod-go info <dependency string>")
} else {
var selectedmod api.Mod = api.GetModData(os.Args[2])
color.Cyan("Mod Info: %s", os.Args[2])
fmt.Println(" Name: " + selectedmod.Versions[0].FullName)
fmt.Println(" Desc: " + selectedmod.Versions[0].Description)
fmt.Println(" Version: " + selectedmod.Versions[0].VersionNumber)
fmt.Println(" Download URL: " + selectedmod.Versions[0].DownloadURL)
}
case "install", "ins", "i":
api.CheckAPICache()
for _, m := range os.Args[2:] {