Reword "mod"/"addon"/"install" to clearer terms across all commands (fixes #138)

This commit is contained in:
comp500
2023-01-20 18:39:23 +00:00
parent eee067964a
commit 79d3ed3957
11 changed files with 57 additions and 67 deletions

View File

@@ -324,7 +324,7 @@ func (u cfUpdater) CheckUpdate(mods []core.Mod, mcVersion string, pack core.Pack
for i, v := range mods {
projectRaw, ok := v.GetParsedUpdateData("curseforge")
if !ok {
results[i] = core.UpdateCheck{Error: errors.New("couldn't parse mod data")}
results[i] = core.UpdateCheck{Error: errors.New("failed to parse update metadata")}
continue
}
project := projectRaw.(cfUpdateData)
@@ -349,7 +349,7 @@ func (u cfUpdater) CheckUpdate(mods []core.Mod, mcVersion string, pack core.Pack
for i, v := range mods {
projectRaw, ok := v.GetParsedUpdateData("curseforge")
if !ok {
results[i] = core.UpdateCheck{Error: errors.New("couldn't parse mod data")}
results[i] = core.UpdateCheck{Error: errors.New("failed to parse update metadata")}
continue
}
project := projectRaw.(cfUpdateData)

View File

@@ -190,11 +190,11 @@ var importCmd = &cobra.Command{
modIDs[i] = v.ProjectID
}
fmt.Println("Querying Curse API for mod info...")
fmt.Println("Querying Curse API for dependency info...")
modInfos, err := cfDefaultClient.getModInfoMultiple(modIDs)
if err != nil {
fmt.Printf("Failed to obtain mod information: %s\n", err)
fmt.Printf("Failed to obtain project information: %s\n", err)
os.Exit(1)
}
@@ -214,7 +214,7 @@ var importCmd = &cobra.Command{
for _, v := range modsList {
modInfoValue, ok := modInfosMap[v.ProjectID]
if !ok {
fmt.Printf("Failed to obtain mod information for addon/file IDs %d/%d\n", v.ProjectID, v.FileID)
fmt.Printf("Failed to obtain information for project/file IDs %d/%d\n", v.ProjectID, v.FileID)
continue
}
@@ -238,7 +238,7 @@ var importCmd = &cobra.Command{
modFileInfos, err := cfDefaultClient.getFileInfoMultiple(remainingFileIDs)
if err != nil {
fmt.Printf("Failed to obtain mod file information: %s\n", err)
fmt.Printf("Failed to obtain project file information: %s\n", err)
os.Exit(1)
}
@@ -250,19 +250,19 @@ var importCmd = &cobra.Command{
for _, v := range modsList {
modInfoValue, ok := modInfosMap[v.ProjectID]
if !ok {
fmt.Printf("Failed to obtain mod information for addon/file IDs %d/%d\n", v.ProjectID, v.FileID)
fmt.Printf("Failed to obtain project information for project/file IDs %d/%d\n", v.ProjectID, v.FileID)
continue
}
modFileInfoValue, ok := modFileInfosMap[v.FileID]
if !ok {
fmt.Printf("Failed to obtain mod file information for addon/file IDs %d/%d\n", v.ProjectID, v.FileID)
fmt.Printf("Failed to obtain project file information for project/file IDs %d/%d\n", v.ProjectID, v.FileID)
continue
}
err = createModFile(modInfoValue, modFileInfoValue, &index, v.OptionalDisabled)
if err != nil {
fmt.Printf("Failed to save mod \"%s\": %s\n", modInfoValue.Name, err)
fmt.Printf("Failed to save project \"%s\": %s\n", modInfoValue.Name, err)
os.Exit(1)
}
@@ -272,11 +272,11 @@ var importCmd = &cobra.Command{
referencedModPaths = append(referencedModPaths, ref)
}
fmt.Printf("Imported mod \"%s\" successfully!\n", modInfoValue.Name)
fmt.Printf("Imported dependency \"%s\" successfully!\n", modInfoValue.Name)
successes++
}
fmt.Printf("Successfully imported %d/%d mods!\n", successes, len(modsList))
fmt.Printf("Successfully imported %d/%d dependencies!\n", successes, len(modsList))
fmt.Println("Reading override files...")
filesList, err := packImport.GetFiles()

View File

@@ -24,9 +24,9 @@ type installableDep struct {
// installCmd represents the install command
var installCmd = &cobra.Command{
Use: "install [URL|slug|search]",
Short: "Install a project from a CurseForge URL, slug, ID or search",
Aliases: []string{"add", "get"},
Use: "add [URL|slug|search]",
Short: "Add a project from a CurseForge URL, slug, ID or search",
Aliases: []string{"install", "get"},
Args: cobra.ArbitraryArgs,
Run: func(cmd *cobra.Command, args []string) {
pack, err := core.LoadPack()

View File

@@ -12,17 +12,11 @@ import (
// openCmd represents the open command
var openCmd = &cobra.Command{
Use: "open",
// TODO: change semantics to "project" rather than "mod", as this supports texture packs and misc content as well?
Short: "Open the project page for a curseforge mod in your browser",
Use: "open [name]",
Short: "Open the project page for a CurseForge file in your browser",
Aliases: []string{"doc"},
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if len(args[0]) == 0 {
fmt.Println("You must specify a mod.")
os.Exit(1)
}
fmt.Println("Loading modpack...")
pack, err := core.LoadPack()
if err != nil {
@@ -36,8 +30,8 @@ var openCmd = &cobra.Command{
}
resolvedMod, ok := index.FindMod(args[0])
if !ok {
// TODO: should this auto-refresh???????
fmt.Println("You don't have this mod installed.")
// TODO: should this auto-refresh?
fmt.Println("Can't find this file; please ensure you have run packwiz refresh and use the name of the .pw.toml file (defaults to the project slug)")
os.Exit(1)
}
modData, err := core.LoadMod(resolvedMod)
@@ -47,7 +41,7 @@ var openCmd = &cobra.Command{
}
updateData, ok := modData.GetParsedUpdateData("curseforge")
if !ok {
fmt.Println("This mod doesn't seem to be a curseforge mod!")
fmt.Println("Can't find CurseForge update metadata for this file")
os.Exit(1)
}
cfUpdateData := updateData.(cfUpdateData)

View File

@@ -86,7 +86,7 @@ func (c *cfApiClient) makePost(endpoint string, body io.Reader) (*http.Response,
type fileType uint8
//noinspection GoUnusedConst
// noinspection GoUnusedConst
const (
fileTypeRelease fileType = iota + 1
fileTypeBeta
@@ -95,7 +95,7 @@ const (
type dependencyType uint8
//noinspection GoUnusedConst
// noinspection GoUnusedConst
const (
dependencyTypeEmbedded dependencyType = iota + 1
dependencyTypeOptional
@@ -107,7 +107,7 @@ const (
type modloaderType uint8
//noinspection GoUnusedConst
// noinspection GoUnusedConst
const (
// modloaderTypeAny should not be passed to the API - it does not work
modloaderTypeAny modloaderType = iota
@@ -138,7 +138,7 @@ var modloaderIds = [...]string{
type hashAlgo uint8
//noinspection GoUnusedConst
// noinspection GoUnusedConst
const (
hashAlgoSHA1 hashAlgo = iota + 1
hashAlgoMD5
@@ -177,16 +177,16 @@ func (c *cfApiClient) getModInfo(modID uint32) (modInfo, error) {
idStr := strconv.FormatUint(uint64(modID), 10)
resp, err := c.makeGet("/v1/mods/" + idStr)
if err != nil {
return modInfo{}, fmt.Errorf("failed to request addon data for ID %d: %w", modID, err)
return modInfo{}, fmt.Errorf("failed to request project data for ID %d: %w", modID, err)
}
err = json.NewDecoder(resp.Body).Decode(&infoRes)
if err != nil && err != io.EOF {
return modInfo{}, fmt.Errorf("failed to request addon data for ID %d: %w", modID, err)
return modInfo{}, fmt.Errorf("failed to request project data for ID %d: %w", modID, err)
}
if infoRes.Data.ID != modID {
return modInfo{}, fmt.Errorf("unexpected addon ID in CurseForge response: %d (expected %d)", infoRes.Data.ID, modID)
return modInfo{}, fmt.Errorf("unexpected project ID in CurseForge response: %d (expected %d)", infoRes.Data.ID, modID)
}
return infoRes.Data, nil
@@ -208,12 +208,12 @@ func (c *cfApiClient) getModInfoMultiple(modIDs []uint32) ([]modInfo, error) {
resp, err := c.makePost("/v1/mods", bytes.NewBuffer(modIDsData))
if err != nil {
return []modInfo{}, fmt.Errorf("failed to request addon data: %w", err)
return []modInfo{}, fmt.Errorf("failed to request project data: %w", err)
}
err = json.NewDecoder(resp.Body).Decode(&infoRes)
if err != nil && err != io.EOF {
return []modInfo{}, fmt.Errorf("failed to request addon data: %w", err)
return []modInfo{}, fmt.Errorf("failed to request project data: %w", err)
}
return infoRes.Data, nil
@@ -279,16 +279,16 @@ func (c *cfApiClient) getFileInfo(modID uint32, fileID uint32) (modFileInfo, err
resp, err := c.makeGet("/v1/mods/" + modIDStr + "/files/" + fileIDStr)
if err != nil {
return modFileInfo{}, fmt.Errorf("failed to request file data for addon ID %d, file ID %d: %w", modID, fileID, err)
return modFileInfo{}, fmt.Errorf("failed to request file data for project ID %d, file ID %d: %w", modID, fileID, err)
}
err = json.NewDecoder(resp.Body).Decode(&infoRes)
if err != nil && err != io.EOF {
return modFileInfo{}, fmt.Errorf("failed to request file data for addon ID %d, file ID %d: %w", modID, fileID, err)
return modFileInfo{}, fmt.Errorf("failed to request file data for project ID %d, file ID %d: %w", modID, fileID, err)
}
if infoRes.Data.ID != fileID {
return modFileInfo{}, fmt.Errorf("unexpected file ID for addon %d in CurseForge response: %d (expected %d)", modID, infoRes.Data.ID, fileID)
return modFileInfo{}, fmt.Errorf("unexpected file ID for project %d in CurseForge response: %d (expected %d)", modID, infoRes.Data.ID, fileID)
}
return infoRes.Data, nil
@@ -366,7 +366,7 @@ func (c *cfApiClient) getSearch(searchTerm string, slug string, gameID uint32, c
type gameStatus uint8
//noinspection GoUnusedConst
// noinspection GoUnusedConst
const (
gameStatusDraft gameStatus = iota + 1
gameStatusTest
@@ -378,7 +378,7 @@ const (
type gameApiStatus uint8
//noinspection GoUnusedConst
// noinspection GoUnusedConst
const (
gameApiStatusPrivate gameApiStatus = iota + 1
gameApiStatusPublic