app: add a config load in init
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
adc978026c
commit
1f4f6f9b75
1 changed files with 23 additions and 1 deletions
24
app.go
24
app.go
|
@ -6,11 +6,33 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "flag"
|
import (
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
config *Config
|
||||||
|
flConfig = flag.String("config", filepath.Join(os.Getenv("HOME"), ".SyncRefs.conf"), "configuration file path")
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
fh, err := os.Open(*flConfig)
|
||||||
|
if err != nil && !os.IsNotExist(err) {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
if fh != nil {
|
||||||
|
config, err = ReadConfig(fh)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build relationships of each group
|
||||||
|
// there needs to be a quit chan to hand off to each watcher and group
|
||||||
for _, arg := range flag.Args() {
|
for _, arg := range flag.Args() {
|
||||||
WatchPath(arg)
|
WatchPath(arg)
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue