Switch to cobra/viper

This commit is contained in:
comp500
2019-09-16 21:44:40 +01:00
parent 8915e16614
commit 4fea7ceebf
17 changed files with 985 additions and 719 deletions

View File

@@ -3,14 +3,16 @@ package core
import (
"path/filepath"
"strings"
"github.com/spf13/viper"
)
// ModExtension is the file extension of the mod metadata files
const ModExtension = ".toml"
// ResolveMod returns the path to a mod file from it's name
func ResolveMod(modName string, flags Flags) string {
func ResolveMod(modName string) string {
// TODO: should this work for any metadata file?
fileName := strings.ToLower(strings.TrimSuffix(modName, ModExtension)) + ModExtension
return filepath.Join(flags.ModsFolder, fileName)
return filepath.Join(viper.GetString("mods-folder"), fileName)
}