mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 13:06:30 +02:00
Pass through optional-disabled on CF import (fixes #93)
This commit is contained in:
parent
7c387f6c83
commit
3fb350f244
13
core/mod.go
13
core/mod.go
@ -23,11 +23,7 @@ type Mod struct {
|
|||||||
Update map[string]map[string]interface{} `toml:"update"`
|
Update map[string]map[string]interface{} `toml:"update"`
|
||||||
updateData map[string]interface{}
|
updateData map[string]interface{}
|
||||||
|
|
||||||
Option *struct {
|
Option *ModOption `toml:"option,omitempty"`
|
||||||
Optional bool `toml:"optional"`
|
|
||||||
Description string `toml:"description,omitempty"`
|
|
||||||
Default bool `toml:"default,omitempty"`
|
|
||||||
} `toml:"option,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ModDownload specifies how to download the mod file
|
// ModDownload specifies how to download the mod file
|
||||||
@ -37,6 +33,13 @@ type ModDownload struct {
|
|||||||
Hash string `toml:"hash"`
|
Hash string `toml:"hash"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ModOption specifies optional metadata for this mod file
|
||||||
|
type ModOption struct {
|
||||||
|
Optional bool `toml:"optional"`
|
||||||
|
Description string `toml:"description,omitempty"`
|
||||||
|
Default bool `toml:"default,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// The three possible values of Side (the side that the mod is on) are "server", "client", and "both".
|
// The three possible values of Side (the side that the mod is on) are "server", "client", and "both".
|
||||||
//noinspection GoUnusedConst
|
//noinspection GoUnusedConst
|
||||||
const (
|
const (
|
||||||
|
@ -162,7 +162,7 @@ func getModIDFromString(mod string) (bool, int, error) {
|
|||||||
return false, 0, nil
|
return false, 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createModFile(modInfo modInfo, fileInfo modFileInfo, index *core.Index) error {
|
func createModFile(modInfo modInfo, fileInfo modFileInfo, index *core.Index, optionalDisabled bool) error {
|
||||||
updateMap := make(map[string]map[string]interface{})
|
updateMap := make(map[string]map[string]interface{})
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
@ -181,6 +181,14 @@ func createModFile(modInfo modInfo, fileInfo modFileInfo, index *core.Index) err
|
|||||||
|
|
||||||
hash, hashFormat := fileInfo.getBestHash()
|
hash, hashFormat := fileInfo.getBestHash()
|
||||||
|
|
||||||
|
var optional *core.ModOption
|
||||||
|
if optionalDisabled {
|
||||||
|
optional = &core.ModOption{
|
||||||
|
Optional: true,
|
||||||
|
Default: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
modMeta := core.Mod{
|
modMeta := core.Mod{
|
||||||
Name: modInfo.Name,
|
Name: modInfo.Name,
|
||||||
FileName: fileInfo.FileName,
|
FileName: fileInfo.FileName,
|
||||||
@ -190,6 +198,7 @@ func createModFile(modInfo modInfo, fileInfo modFileInfo, index *core.Index) err
|
|||||||
HashFormat: hashFormat,
|
HashFormat: hashFormat,
|
||||||
Hash: hash,
|
Hash: hash,
|
||||||
},
|
},
|
||||||
|
Option: optional,
|
||||||
Update: updateMap,
|
Update: updateMap,
|
||||||
}
|
}
|
||||||
path := modMeta.SetMetaName(modInfo.Slug, *index)
|
path := modMeta.SetMetaName(modInfo.Slug, *index)
|
||||||
|
@ -88,7 +88,7 @@ var detectCmd = &cobra.Command{
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createModFile(modInfoData, v.File, &index)
|
err = createModFile(modInfoData, v.File, &index, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -262,7 +262,7 @@ var importCmd = &cobra.Command{
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createModFile(modInfoValue, modFileInfoValue, &index)
|
err = createModFile(modInfoValue, modFileInfoValue, &index, v.OptionalDisabled)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("Failed to save mod \"%s\": %s\n", modInfoValue.Name, err)
|
fmt.Printf("Failed to save mod \"%s\": %s\n", modInfoValue.Name, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -215,7 +215,7 @@ var installCmd = &cobra.Command{
|
|||||||
ansNormal := strings.ToLower(strings.TrimSpace(answer))
|
ansNormal := strings.ToLower(strings.TrimSpace(answer))
|
||||||
if !(len(ansNormal) > 0 && ansNormal[0] == 'n') {
|
if !(len(ansNormal) > 0 && ansNormal[0] == 'n') {
|
||||||
for _, v := range depsInstallable {
|
for _, v := range depsInstallable {
|
||||||
err = createModFile(v.modInfo, v.fileInfo, &index)
|
err = createModFile(v.modInfo, v.fileInfo, &index, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -229,7 +229,7 @@ var installCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = createModFile(modInfoData, fileInfoData, &index)
|
err = createModFile(modInfoData, fileInfoData, &index, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user