mark2web/config_global.go

48 lines
870 B
Go
Raw Normal View History

2019-03-18 15:14:41 +01:00
package mark2web
2019-02-27 17:33:26 +01:00
import (
"io/ioutil"
"gopkg.in/yaml.v2"
)
// GlobalConfig is config which is used only once in root dir
type GlobalConfig struct {
Webserver struct {
Type string `yaml:"Type"`
} `yaml:"Webserver"`
Assets struct {
FromPath string `yaml:"FromPath"`
ToPath string `yaml:"ToPath"`
Action string `yaml:"Action"`
FixTemplate struct {
Find string `yaml:"Find"`
Replace string `yaml:"Replace"`
} `yaml:"FixTemplate"`
} `yaml:"Assets"`
OtherFiles struct {
Action string `yaml:"Action"`
} `yaml:"OtherFiles"`
2019-02-28 12:13:28 +01:00
Directories struct {
Input string
Output string
}
2019-02-27 17:33:26 +01:00
}
var Config = new(GlobalConfig)
2019-03-18 15:14:41 +01:00
func (c *GlobalConfig) ReadFromFile(filename string) error {
2019-02-27 17:33:26 +01:00
data, err := ioutil.ReadFile(filename)
if err != nil {
return err
}
2019-03-18 15:14:41 +01:00
err = yaml.Unmarshal(data, c)
2019-02-27 17:33:26 +01:00
if err != nil {
return err
}
return nil
}