Work in progress

This commit is contained in:
Alex Yatskov 2015-03-31 20:59:09 +09:00
parent 6aaf319a85
commit 66a8182942
2 changed files with 31 additions and 25 deletions

View File

@ -13,30 +13,30 @@ force = false
src = ".gitconfig" src = ".gitconfig"
[profs.base] [profs.base]
[[profs.dev.links]] [[profs.base.links]]
src = ".config/fish" src = ".config/fish"
[[profs.dev.links]] [[profs.base.links]]
src = ".config/keepassx" src = ".config/keepassx"
[[profs.dev.links]] [[profs.base.links]]
src = ".filezilla" src = ".filezilla"
[[profs.dev.links]] [[profs.base.links]]
src = "profsile" src = "profsile"
[profs.study] [profs.study]
[[profs.dev.links]] [[profs.study.links]]
src = "Anki" src = "Anki"
[[profs.dev.links]] [[profs.study.links]]
src = ".yomichan.json" src = ".yomichan.json"
[profs.net] [profs.net]
[[profs.dev.links]] [[profs.net.links]]
src = ".filezilla" src = ".filezilla"
[[profs.dev.links]] [[profs.net.links]]
src = ".s3cfg" src = ".s3cfg"
[profs.flatline] [profs.flatline]
@ -44,11 +44,11 @@ force = false
stomp = true stomp = true
force = true force = true
[[profs.dev.links]] [[profs.flatline.links]]
src = ".ssh_flatline" src = ".ssh_flatline"
dst = ".ssh" dst = ".ssh"
[[profs.dev.links]] [[profs.flatline.links]]
src = ".config/syncthing_flatline" src = ".config/syncthing_flatline"
dst = ".config/syncthing" dst = ".config/syncthing"
@ -57,6 +57,6 @@ force = false
stomp = true stomp = true
force = true force = true
[[profs.dev.links]] [[profs.wintermute.links]]
src = ".ssh_wintermute" src = ".ssh_wintermute"
dst = ".ssh" dst = ".ssh"

34
main.go
View File

@ -26,7 +26,6 @@ import (
"github.com/naoina/toml" "github.com/naoina/toml"
"io/ioutil" "io/ioutil"
"log" "log"
"os"
) )
type link struct { type link struct {
@ -49,22 +48,29 @@ type config struct {
Stomp bool Stomp bool
} }
func main() { func parse(filename string) (*config, error) {
f, err := os.Open("config.toml") bytes, err := ioutil.ReadFile(filename)
if err != nil { if err != nil {
log.Fatal(err) return nil, err
}
defer f.Close()
buff, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal(err)
} }
var conf config conf := &config{}
if err := toml.Unmarshal(buff, &conf); err != nil { if err := toml.Unmarshal(bytes, &conf); err != nil {
log.Fatal(err) 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)
} }