|
24 | 24 | autoYes bool |
25 | 25 | mcVersionFlag string // override MC version |
26 | 26 | loaderFlag string // override loader |
27 | | - verbose bool // enable verbose logging |
| 27 | + verbose bool // enable verbose logging |
28 | 28 | ) |
29 | 29 |
|
30 | 30 | func main() { |
@@ -278,12 +278,33 @@ func main() { |
278 | 278 | if err := SaveConfig(cfgFile, cfg); err != nil { |
279 | 279 | return err |
280 | 280 | } |
281 | | - fmt.Printf("Deleted modpack %q\n", name) |
282 | | - // Also remove associated state and mods directory? |
283 | | - // state, _ := LoadState(stateFile) |
284 | | - // delete(state, name) |
285 | | - // SaveState(stateFile, state) |
286 | | - // os.RemoveAll(filepath.Join(modsDir, name)) |
| 281 | + fmt.Printf("Deleted modpack %q from config\n", name) |
| 282 | + |
| 283 | + // --- Remove state entry --- |
| 284 | + state, err := LoadState(stateFile) |
| 285 | + if err != nil { |
| 286 | + fmt.Printf("Warning: could not load state file: %v\n", err) |
| 287 | + } else { |
| 288 | + if _, ok := state[name]; ok { |
| 289 | + delete(state, name) |
| 290 | + if err := SaveState(stateFile, state); err != nil { |
| 291 | + fmt.Printf("Warning: could not save updated state file: %v\n", err) |
| 292 | + } else if verbose { |
| 293 | + fmt.Printf("Removed state for %q\n", name) |
| 294 | + } |
| 295 | + } else if verbose { |
| 296 | + fmt.Printf("No state found for %q\n", name) |
| 297 | + } |
| 298 | + } |
| 299 | + |
| 300 | + // --- Remove mods directory --- |
| 301 | + dir := filepath.Join(modsDir, name) |
| 302 | + if err := os.RemoveAll(dir); err != nil { |
| 303 | + fmt.Printf("Warning: failed to remove mods directory %s: %v\n", dir, err) |
| 304 | + } else if verbose { |
| 305 | + fmt.Printf("Removed mods directory %s\n", dir) |
| 306 | + } |
| 307 | + |
287 | 308 | return nil |
288 | 309 | }, |
289 | 310 | } |
@@ -436,7 +457,7 @@ func main() { |
436 | 457 | continue |
437 | 458 | } |
438 | 459 |
|
439 | | - // --- Perform Download --- |
| 460 | + // --- Perform Download --- |
440 | 461 |
|
441 | 462 | // Remove old file ONLY if it exists AND the new filename is different |
442 | 463 | if fileExists && expectedFilePath != "" && modState.Filename != ver.Files[0].Filename { |
@@ -490,7 +511,7 @@ func main() { |
490 | 511 |
|
491 | 512 | // check-updates |
492 | 513 | checkUpdatesCmd := &cobra.Command{ |
493 | | - Use: "check-updates [modpack]", // Renamed from "status" |
| 514 | + Use: "check-updates [modpack]", // Renamed from "status" |
494 | 515 | Short: "Check Modrinth for newer versions of mods in a modpack", // Updated description |
495 | 516 | Args: cobra.ExactArgs(1), |
496 | 517 | RunE: func(cmd *cobra.Command, args []string) error { |
|
0 commit comments