Add --output/-o flags for Modrinth/Curseforge export (fixes #38)

This commit is contained in:
comp500 2022-02-27 17:44:44 +00:00
parent 2dd0a1ae78
commit 7c387f6c83
2 changed files with 12 additions and 2 deletions

View File

@ -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) expFile, err := os.Create(fileName)
if err != nil { if err != nil {
@ -260,4 +263,6 @@ func init() {
exportCmd.Flags().StringP("side", "s", "client", "The side to export mods with") exportCmd.Flags().StringP("side", "s", "client", "The side to export mods with")
_ = viper.BindPFlag("curseforge.export.side", exportCmd.Flags().Lookup("side")) _ = 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"))
} }

View File

@ -56,7 +56,10 @@ var exportCmd = &cobra.Command{
mods := loadMods(index) 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) expFile, err := os.Create(fileName)
if err != nil { if err != nil {
fmt.Printf("Failed to create zip: %s\n", err.Error()) fmt.Printf("Failed to create zip: %s\n", err.Error())
@ -251,4 +254,6 @@ func loadMods(index core.Index) []core.Mod {
func init() { func init() {
modrinthCmd.AddCommand(exportCmd) modrinthCmd.AddCommand(exportCmd)
exportCmd.Flags().StringP("output", "o", "", "The file to export the modpack to")
_ = viper.BindPFlag("modrinth.export.output", exportCmd.Flags().Lookup("output"))
} }