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 = true
force = false
[home.dev]
[[links]]
[profs.dev]
[[profs.dev.links]]
src = "vim/.vimrc"
dst = ".vimrc"
[[links]]
[[profs.dev.links]]
src = "vim/.vim"
dst = ".vim"
[[links]]
[[profs.dev.links]]
src = ".gitconfig"
[home.base]
[[links]]
[profs.base]
[[profs.dev.links]]
src = ".config/fish"
[[links]]
[[profs.dev.links]]
src = ".config/keepassx"
[[links]]
[[profs.dev.links]]
src = ".filezilla"
[[links]]
src = "profile"
[[profs.dev.links]]
src = "profsile"
[home.study]
[[links]]
[profs.study]
[[profs.dev.links]]
src = "Anki"
[[links]]
[[profs.dev.links]]
src = ".yomichan.json"
[home.net]
[[links]]
[profs.net]
[[profs.dev.links]]
src = ".filezilla"
[[links]]
[[profs.dev.links]]
src = ".s3cfg"
[[flatline]]
[profs.flatline]
deps = ["base", "dev", "study", "net"]
stomp = true
force = true
[[links]]
[[profs.dev.links]]
src = ".ssh_flatline"
dst = ".ssh"
[[links]]
[[profs.dev.links]]
src = ".config/syncthing_flatline"
dst = ".config/syncthing"
[[wintermute]]
[profs.wintermute]
deps = ["base", "dev", "study"]
stomp = true
force = true
[[links]]
[[profs.dev.links]]
src = ".ssh_wintermute"
dst = ".ssh"

45
main.go
View File

@ -22,6 +22,49 @@
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"])
}