mirror of
https://github.com/kovetskiy/mark.git
synced 2026-05-01 21:02:33 +00:00
config: use ko
This commit is contained in:
24
main.go
24
main.go
@@ -7,14 +7,12 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/kovetskiy/godocs"
|
||||
"github.com/kovetskiy/lorg"
|
||||
"github.com/kovetskiy/mark/pkg/confluence"
|
||||
"github.com/kovetskiy/mark/pkg/mark"
|
||||
"github.com/reconquest/cog"
|
||||
"github.com/reconquest/karma-go"
|
||||
"github.com/zazab/zhash"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -121,8 +119,8 @@ func main() {
|
||||
|
||||
initlog(args["--debug"].(bool), args["--trace"].(bool))
|
||||
|
||||
config, err := getConfig(filepath.Join(os.Getenv("HOME"), ".config/mark"))
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
config, err := LoadConfig(filepath.Join(os.Getenv("HOME"), ".config/mark"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -321,21 +319,3 @@ func resolvePage(
|
||||
|
||||
return page, nil
|
||||
}
|
||||
|
||||
func getConfig(path string) (zhash.Hash, error) {
|
||||
configData := map[string]interface{}{}
|
||||
_, err := toml.DecodeFile(path, &configData)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return zhash.NewHash(), err
|
||||
}
|
||||
|
||||
return zhash.NewHash(), karma.Format(
|
||||
err,
|
||||
"can't decode toml file: %s",
|
||||
path,
|
||||
)
|
||||
}
|
||||
|
||||
return zhash.HashFromMap(configData), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user