mirror of
https://github.com/packwiz/packwiz.git
synced 2025-10-14 06:54:32 +02:00
Use the correct directories for non-mod files; use .pw.toml extension
The mods-folder option is now replaced with two new options: meta-folder and meta-folder-base This allows non-mod files to use the correct directory based on their category; with correct import of resource packs/etc from CurseForge packs, and the ability to override this behaviour. To improve the reliability of packwiz metadata file marking (in the index), new files now use .pw.toml as the extension - any extension can be used, but .pw.toml will now be automatically be marked as a metafile regardless of folder, so you can easily move metadata files around. Existing metadata files will still work (as metafile = true is set in the index); though in the future .pw.toml may be required.
This commit is contained in:
20
cmd/root.go
20
cmd/root.go
@@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/packwiz/packwiz/core"
|
||||
"github.com/spf13/pflag"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -11,7 +12,6 @@ import (
|
||||
)
|
||||
|
||||
var packFile string
|
||||
var modsFolder string
|
||||
var cfgFile string
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
@@ -38,8 +38,22 @@ func init() {
|
||||
rootCmd.PersistentFlags().StringVar(&packFile, "pack-file", "pack.toml", "The modpack metadata file to use")
|
||||
_ = viper.BindPFlag("pack-file", rootCmd.PersistentFlags().Lookup("pack-file"))
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&modsFolder, "mods-folder", "mods", "The default folder to store mod metadata files in")
|
||||
_ = viper.BindPFlag("mods-folder", rootCmd.PersistentFlags().Lookup("mods-folder"))
|
||||
// Make mods-folder an alias for meta-folder
|
||||
viper.RegisterAlias("mods-folder", "meta-folder")
|
||||
rootCmd.SetGlobalNormalizationFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
|
||||
if name == "mods-folder" {
|
||||
return "meta-folder"
|
||||
}
|
||||
return pflag.NormalizedName(name)
|
||||
})
|
||||
|
||||
var metaFolder string
|
||||
rootCmd.PersistentFlags().StringVar(&metaFolder, "meta-folder", "", "The folder in which new metadata files will be added, defaulting to a folder based on the category (mods, resourcepacks, etc; if the category is unknown the current directory is used)")
|
||||
_ = viper.BindPFlag("meta-folder", rootCmd.PersistentFlags().Lookup("meta-folder"))
|
||||
|
||||
var metaFolderBase string
|
||||
rootCmd.PersistentFlags().StringVar(&metaFolderBase, "meta-folder-base", ".", "The base folder from which meta-folder will be resolved, defaulting to the current directory (so you can put all mods/etc in a subfolder while still using the default behaviour)")
|
||||
_ = viper.BindPFlag("meta-folder-base", rootCmd.PersistentFlags().Lookup("meta-folder-base"))
|
||||
|
||||
file, err := core.GetPackwizLocalStore()
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user