Use map structure to allow for multiple compile targets
This commit is contained in:
parent
aaa87a06e4
commit
9c7f2f503d
@ -26,12 +26,13 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
settingsFile = "ponder.json"
|
settingsFile = "ponder.json"
|
||||||
settingsTemplate = []byte(`{
|
settingsTemplate = []byte(`{ "default" : {
|
||||||
"Name": "",
|
"Name": "",
|
||||||
"Author": "",
|
"Author": "",
|
||||||
"IgnoreDirs": [".git"],
|
"IgnoreDirs": [".git"],
|
||||||
"LilypondIncludes": [],
|
"LilypondIncludes": [],
|
||||||
"OutputDir": "out"
|
"OutputDir": "out"
|
||||||
|
}
|
||||||
}`)
|
}`)
|
||||||
gitIgnoreTemplate = []byte(`# Output Folder
|
gitIgnoreTemplate = []byte(`# Output Folder
|
||||||
out/`)
|
out/`)
|
||||||
|
@ -77,5 +77,7 @@ func getSettings() (string, *settings.Settings) {
|
|||||||
opts, err := settings.FromFile(filepath.Join(path, settingsFile))
|
opts, err := settings.FromFile(filepath.Join(path, settingsFile))
|
||||||
helpers.Check(err, "unable to parse settings file")
|
helpers.Check(err, "unable to parse settings file")
|
||||||
|
|
||||||
return path, opts
|
set := opts["default"]
|
||||||
|
|
||||||
|
return path, &set
|
||||||
}
|
}
|
||||||
|
@ -44,19 +44,23 @@ type Settings struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FromFile reads a settings file in json format and returns the Settings struct
|
// FromFile reads a settings file in json format and returns the Settings struct
|
||||||
func FromFile(path string) (*Settings, error) {
|
func FromFile(path string) (map[string]Settings, error) {
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := ioutil.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var s Settings
|
s := make(map[string]Settings)
|
||||||
err = json.Unmarshal(data, &s)
|
err = json.Unmarshal(data, &s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.AbsolutePaths(filepath.Dir(path))
|
for i := range s {
|
||||||
return &s, nil
|
set := s[i]
|
||||||
|
set.AbsolutePaths(filepath.Dir(path))
|
||||||
|
s[i] = set
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbsolutePaths makes all paths in settings absolute using the given
|
// AbsolutePaths makes all paths in settings absolute using the given
|
||||||
|
Reference in New Issue
Block a user