From 7c387f6c83b124df8d74bd2aa5afa6c0efbb8170 Mon Sep 17 00:00:00 2001 From: comp500 Date: Sun, 27 Feb 2022 17:44:44 +0000 Subject: [PATCH] Add --output/-o flags for Modrinth/Curseforge export (fixes #38) --- curseforge/export.go | 7 ++++++- modrinth/export.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/curseforge/export.go b/curseforge/export.go index a476f1e..39c11a2 100644 --- a/curseforge/export.go +++ b/curseforge/export.go @@ -84,7 +84,10 @@ var exportCmd = &cobra.Command{ } } - var fileName = pack.GetPackName() + ".zip" + fileName := viper.GetString("curseforge.export.output") + if fileName == "" { + fileName = pack.GetPackName() + ".zip" + } expFile, err := os.Create(fileName) if err != nil { @@ -260,4 +263,6 @@ func init() { exportCmd.Flags().StringP("side", "s", "client", "The side to export mods with") _ = viper.BindPFlag("curseforge.export.side", exportCmd.Flags().Lookup("side")) + exportCmd.Flags().StringP("output", "o", "", "The file to export the modpack to") + _ = viper.BindPFlag("curseforge.export.output", exportCmd.Flags().Lookup("output")) } diff --git a/modrinth/export.go b/modrinth/export.go index 79a8036..9a7827f 100644 --- a/modrinth/export.go +++ b/modrinth/export.go @@ -56,7 +56,10 @@ var exportCmd = &cobra.Command{ mods := loadMods(index) - var fileName = pack.GetPackName() + ".mrpack" + fileName := viper.GetString("modrinth.export.output") + if fileName == "" { + fileName = pack.GetPackName() + ".mrpack" + } expFile, err := os.Create(fileName) if err != nil { fmt.Printf("Failed to create zip: %s\n", err.Error()) @@ -251,4 +254,6 @@ func loadMods(index core.Index) []core.Mod { func init() { modrinthCmd.AddCommand(exportCmd) + exportCmd.Flags().StringP("output", "o", "", "The file to export the modpack to") + _ = viper.BindPFlag("modrinth.export.output", exportCmd.Flags().Lookup("output")) }