Some initial parsing

This commit is contained in:
Alex Yatskov 2015-03-31 14:51:43 +09:00
parent 99b5c7e39e
commit 6aaf319a85
2 changed files with 70 additions and 24 deletions

View File

@ -1,59 +1,62 @@
stomp = true force = false
force = true
[home.dev] [profs.dev]
[[links]] [[profs.dev.links]]
src = "vim/.vimrc" src = "vim/.vimrc"
dst = ".vimrc" dst = ".vimrc"
[[links]] [[profs.dev.links]]
src = "vim/.vim" src = "vim/.vim"
dst = ".vim" dst = ".vim"
[[links]] [[profs.dev.links]]
src = ".gitconfig" src = ".gitconfig"
[home.base] [profs.base]
[[links]] [[profs.dev.links]]
src = ".config/fish" src = ".config/fish"
[[links]] [[profs.dev.links]]
src = ".config/keepassx" src = ".config/keepassx"
[[links]] [[profs.dev.links]]
src = ".filezilla" src = ".filezilla"
[[links]] [[profs.dev.links]]
src = "profile" src = "profsile"
[home.study] [profs.study]
[[links]] [[profs.dev.links]]
src = "Anki" src = "Anki"
[[links]] [[profs.dev.links]]
src = ".yomichan.json" src = ".yomichan.json"
[home.net] [profs.net]
[[links]] [[profs.dev.links]]
src = ".filezilla" src = ".filezilla"
[[links]] [[profs.dev.links]]
src = ".s3cfg" src = ".s3cfg"
[[flatline]] [profs.flatline]
deps = ["base", "dev", "study", "net"] deps = ["base", "dev", "study", "net"]
stomp = true
force = true
[[links]] [[profs.dev.links]]
src = ".ssh_flatline" src = ".ssh_flatline"
dst = ".ssh" dst = ".ssh"
[[links]] [[profs.dev.links]]
src = ".config/syncthing_flatline" src = ".config/syncthing_flatline"
dst = ".config/syncthing" dst = ".config/syncthing"
[[wintermute]] [profs.wintermute]
deps = ["base", "dev", "study"] deps = ["base", "dev", "study"]
stomp = true
force = true
[[links]] [[profs.dev.links]]
src = ".ssh_wintermute" src = ".ssh_wintermute"
dst = ".ssh" dst = ".ssh"

45
main.go
View File

@ -22,6 +22,49 @@
package main package main
func main() { import (
"github.com/naoina/toml"
"io/ioutil"
"log"
"os"
)
type link struct {
Dst string
Force bool
Src string
Stomp bool
}
type profile struct {
Deps []string
Force bool
Links []link
Stomp bool
}
type config struct {
Force bool
Profs map[string]profile
Stomp bool
}
func main() {
f, err := os.Open("config.toml")
if err != nil {
log.Fatal(err)
}
defer f.Close()
buff, err := ioutil.ReadAll(f)
if err != nil {
log.Fatal(err)
}
var conf config
if err := toml.Unmarshal(buff, &conf); err != nil {
log.Fatal(err)
}
log.Print(conf.Profs["dev"])
} }