File writing, index sorting

This commit is contained in:
comp500
2019-04-25 19:22:02 +01:00
parent d6b55b8032
commit 64a73afdf7
4 changed files with 85 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
package core
import (
"fmt"
"io/ioutil"
"github.com/BurntSushi/toml"
)
@@ -20,8 +20,18 @@ type Pack struct {
// LoadPack loads the modpack metadata to a Pack struct
func LoadPack(flags Flags) (Pack, error) {
fmt.Println(flags.PackFile)
// TODO implement
return Pack{}, nil
data, err := ioutil.ReadFile(flags.PackFile)
if err != nil {
return Pack{}, err
}
var modpack Pack
if _, err := toml.Decode(string(data), &modpack); err != nil {
return Pack{}, err
}
if len(modpack.Index.File) == 0 {
modpack.Index.File = "index.toml"
}
return modpack, nil
}