Skip to content

Commit

Permalink
Merge pull request #23 from m-triassi/21-command-readout
Browse files Browse the repository at this point in the history
Add readout that shows downloaded files
  • Loading branch information
m-triassi authored Feb 1, 2024
2 parents 4ba9023 + a1b76fa commit ab43ab1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ update that addon in isolation.`,
panic(fmt.Errorf("Failed to fetch files from CurseForge, mod id may not exist: %w", err))
}

file, err := curseforge.DownloadFile(modId, curseforge.NegotiateFile(files))
negotiated := curseforge.NegotiateFile(files)
fmt.Printf("Downloading: %s... ", negotiated.Filename)
file, err := curseforge.DownloadFile(modId, negotiated)
if err != nil {
panic(fmt.Errorf("Could not download file: %w", err))
}

dest := viper.GetString("install")

fmt.Printf("Unpacking... ")
err = curseforge.InstallAddon(file, dest)
if err != nil {
panic(fmt.Errorf("Failed to install addon in target destination"))
Expand All @@ -52,6 +55,7 @@ update that addon in isolation.`,
viper.Set("addons", list)
viper.WriteConfig()
}
fmt.Printf("[INSTALLED]\n")
},
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ the associated files for that addon.`,

re := regexp.MustCompile("[a-zA-Z]*")
res := string(re.Find([]byte(filename)))
fmt.Printf("Deleting: %s... ", res)

installPath := viper.GetString("install")
del, err := filepath.Glob(installPath + res + "*")
Expand All @@ -45,6 +46,7 @@ the associated files for that addon.`,
}

filesystem.DeleteAll(del)
fmt.Printf("[DELETED]\n")

viper.Set("addons", addons)
viper.WriteConfig()
Expand Down
7 changes: 6 additions & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ Simply run the command and all files will be downloaded and unpacked.
panic(fmt.Errorf("Failed to fetch files from CurseForge, mod id (%d) may not exist: %w", id, err))
}

file, err := curseforge.DownloadFile(id, curseforge.NegotiateFile(files))
negotiated := curseforge.NegotiateFile(files)
fmt.Printf("\nDownloading: %s... ", negotiated.Filename)
file, err := curseforge.DownloadFile(id, negotiated)
if err != nil {
panic(fmt.Errorf("Could not download file: %w", err))
}

fmt.Printf("Unpacking... ")
dest := viper.GetString("install")
err = curseforge.InstallAddon(file, dest)
if err != nil {
panic(fmt.Errorf("Failed to install addon in target destination"))
}

fmt.Printf("[INSTALLED]\n")
}
},
}
Expand Down

0 comments on commit ab43ab1

Please sign in to comment.