diff --git a/config.toml b/config.toml index 85a52ca..7cb83bd 100644 --- a/config.toml +++ b/config.toml @@ -13,30 +13,30 @@ force = false src = ".gitconfig" [profs.base] - [[profs.dev.links]] + [[profs.base.links]] src = ".config/fish" - [[profs.dev.links]] + [[profs.base.links]] src = ".config/keepassx" - [[profs.dev.links]] + [[profs.base.links]] src = ".filezilla" - [[profs.dev.links]] + [[profs.base.links]] src = "profsile" [profs.study] - [[profs.dev.links]] + [[profs.study.links]] src = "Anki" - [[profs.dev.links]] + [[profs.study.links]] src = ".yomichan.json" [profs.net] - [[profs.dev.links]] + [[profs.net.links]] src = ".filezilla" - [[profs.dev.links]] + [[profs.net.links]] src = ".s3cfg" [profs.flatline] @@ -44,11 +44,11 @@ force = false stomp = true force = true - [[profs.dev.links]] + [[profs.flatline.links]] src = ".ssh_flatline" dst = ".ssh" - [[profs.dev.links]] + [[profs.flatline.links]] src = ".config/syncthing_flatline" dst = ".config/syncthing" @@ -57,6 +57,6 @@ force = false stomp = true force = true - [[profs.dev.links]] + [[profs.wintermute.links]] src = ".ssh_wintermute" dst = ".ssh" diff --git a/main.go b/main.go index 345e7e7..079d763 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,6 @@ import ( "github.com/naoina/toml" "io/ioutil" "log" - "os" ) type link struct { @@ -49,22 +48,29 @@ type config struct { Stomp bool } -func main() { - f, err := os.Open("config.toml") +func parse(filename string) (*config, error) { + bytes, err := ioutil.ReadFile(filename) if err != nil { - log.Fatal(err) - } - defer f.Close() - - buff, err := ioutil.ReadAll(f) - if err != nil { - log.Fatal(err) + return nil, err } - var conf config - if err := toml.Unmarshal(buff, &conf); err != nil { - log.Fatal(err) + conf := &config{} + if err := toml.Unmarshal(bytes, &conf); err != nil { + return nil, err } - log.Print(conf.Profs["dev"]) + return conf, nil +} + +func process(src, dst string) error { + return nil +} + +func main() { + conf, err := parse("config.toml") + if err != nil { + log.Fatal(err) + } + + log.Print(conf) }