Work in progress
This commit is contained in:
parent
52b647e16d
commit
834bccdace
37
main.go
37
main.go
@ -23,9 +23,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/naoina/toml"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
func parse(filename string) (*config, error) {
|
||||
@ -42,13 +44,42 @@ func parse(filename string) (*config, error) {
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
func install(conf config, name, target, source string, force, clobber bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func uninstall(conf config, name, target string, force, clobber bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
conf, err := parse("config.toml")
|
||||
currUsr, err := user.Current()
|
||||
if err == nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
action := flag.String("action", "install", "'install' or 'uninstall' symlinks")
|
||||
clobber := flag.Bool("clobber", false, "delete files and directories at target")
|
||||
force := flag.Bool("force", true, "force creation of parent directories for target")
|
||||
profile := flag.String("profile", "default", "name of profile to execute")
|
||||
target := flag.String("target", currUsr.HomeDir, "target directory for symlinks")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
confPath := flag.Arg(0)
|
||||
source := flag.Arg(1)
|
||||
|
||||
conf, err := parse(confPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := conf.process("flatline", "/mnt/storage/sync/Dropbox", "/mnt/storage/projects/blah"); err != nil {
|
||||
log.Fatal(err)
|
||||
switch *action {
|
||||
case "install":
|
||||
install(*conf, *profile, *target, source, *force, *clobber)
|
||||
case "uninstall":
|
||||
uninstall(*conf, *profile, *target, *force, *clobber)
|
||||
default:
|
||||
log.Fatalf("Unrecognized action: '%s'", action)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user