mirror of
https://github.com/packwiz/packwiz.git
synced 2025-05-05 12:06:31 +02:00
Add --cache flag to export commands (#133)
This option allow overriding the cache directory An 'cache.directory' entry has also been added in the config
This commit is contained in:
parent
b8be3784f6
commit
d051932bbb
@ -55,6 +55,14 @@ func init() {
|
|||||||
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)")
|
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"))
|
_ = viper.BindPFlag("meta-folder-base", rootCmd.PersistentFlags().Lookup("meta-folder-base"))
|
||||||
|
|
||||||
|
defaultCacheDir, err := core.GetPackwizCache()
|
||||||
|
cacheUsage := "The directory where packwiz will cache downloaded mods"
|
||||||
|
if err == nil {
|
||||||
|
cacheUsage += "(default \""+defaultCacheDir+"\")"
|
||||||
|
}
|
||||||
|
rootCmd.PersistentFlags().String("cache", defaultCacheDir, cacheUsage)
|
||||||
|
_ = viper.BindPFlag("cache.directory", rootCmd.PersistentFlags().Lookup("cache"))
|
||||||
|
|
||||||
file, err := core.GetPackwizLocalStore()
|
file, err := core.GetPackwizLocalStore()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -4,6 +4,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetPackwizLocalStore() (string, error) {
|
func GetPackwizLocalStore() (string, error) {
|
||||||
@ -54,6 +56,10 @@ func GetPackwizInstallBinFile() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetPackwizCache() (string, error) {
|
func GetPackwizCache() (string, error) {
|
||||||
|
configuredCache := viper.GetString("cache.directory")
|
||||||
|
if configuredCache != "" {
|
||||||
|
return configuredCache, nil
|
||||||
|
}
|
||||||
localStore, err := GetPackwizLocalCache()
|
localStore, err := GetPackwizLocalCache()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user