]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync_changes.go
changes: display "no changes" when nothing was changed
[safcm/safcm.git] / cmd / safcm / sync_changes.go
index 6327fd9addbaec497a31452a635082cb6f65b32e..3e91768bfca3eb3273e5c24954c506f86934a63b 100644 (file)
@@ -49,9 +49,19 @@ func (s *Sync) formatChanges(resp safcm.MsgSyncResp) string {
                        s.formatCommandChanges(resp.CommandChanges))
        }
        if len(changes) == 0 {
-               return ""
+               // Notify user that the host was synced successfully
+               return "no changes"
        }
-       return "\n" + strings.Join(changes, "\n")
+
+       x := strings.Join(changes, "\n")
+       // If quiet is used and only commands without output were executed
+       // then don't prepend a newline so that the whole change output of a
+       // host fits in a single line. This makes the output much more
+       // readable with multiple hosts.
+       if strings.Count(x, "\n") == 1 {
+               return x
+       }
+       return "\n" + x
 }
 
 func (s *Sync) formatFileChanges(changes []safcm.FileChange) string {