aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..345436f
--- /dev/null
+++ b/main.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "flag"
+ "log"
+)
+
+var (
+ hostDir = flag.String("host", "/host", "Host source directory (read-only)")
+ dataDir = flag.String("data", "/data", "Data destination directory")
+ verbose = flag.Bool("verbose", false, "Enable verbose logging")
+ dryRun = flag.Bool("dry-run", false, "Preview what would be synced without copying")
+)
+
+func main() {
+ flag.Parse()
+ log.SetFlags(log.LstdFlags | log.Lshortfile)
+
+ if *verbose {
+ log.Println("sourcewatch starting...")
+ log.Printf("host: %s, data: %s, dry-run: %v", *hostDir, *dataDir, *dryRun)
+ }
+
+ rules, err := loadGitignore(*hostDir)
+ if err != nil {
+ log.Fatalf("failed to load .gitignore: %v", err)
+ }
+
+ manifest, err := initialSync(*hostDir, *dataDir, rules, *dryRun)
+ if err != nil {
+ log.Fatalf("initial sync failed: %v", err)
+ }
+
+ if err := watch(*hostDir, *dataDir, manifest, rules, *dryRun, *verbose); err != nil {
+ log.Fatalf("watcher failed: %v", err)
+ }
+}