]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync_sync.go
frontend: add Loop.HostSyncMsg()
[safcm/safcm.git] / cmd / safcm / sync_sync.go
index 0d5a722d9ef59b0461550532adcef372725db767..01e712c50f552d8296491c2a3ea515432ff46006 100644 (file)
@@ -21,12 +21,12 @@ import (
        "fmt"
        "math"
        "os"
-       "path/filepath"
        "sort"
        "strings"
 
        "ruderich.org/simon/safcm"
        "ruderich.org/simon/safcm/cmd/safcm/config"
+       "ruderich.org/simon/safcm/frontend"
        "ruderich.org/simon/safcm/rpc"
 )
 
@@ -35,17 +35,18 @@ func (s *Sync) hostSync(conn *rpc.Conn, detectedGroups []string) error {
        if err != nil {
                return err
        }
-       x, err := s.sendRecv(conn, req)
+       resp, err := s.loop.HostSyncMsg(s, conn, req)
        if err != nil {
                return err
        }
-       resp, ok := x.(safcm.MsgSyncResp)
-       if !ok {
-               return fmt.Errorf("unexpected response %v", x)
-       }
 
        // Display changes
-       changes := s.formatChanges(resp)
+       c := frontend.Changes{
+               DryRun: s.config.DryRun,
+               Quiet:  s.config.Quiet,
+               IsTTY:  s.isTTY,
+       }
+       changes := c.FormatChanges(resp)
        if changes != "" {
                s.log(safcm.LogInfo, true, changes)
        }
@@ -255,7 +256,8 @@ func resolveFileDirConflicts(files map[string]*safcm.File) {
                return paths[i] < paths[j]
        })
 
-       const sep = string(filepath.Separator)
+       // Slash separated paths are used for the configuration
+       const sep = "/"
 
        // Remove invalid paths which can result from group_priority
        // overriding paths from another group (e.g. "/foo" as file from one