+func (s *Sync) formatChanges(resp safcm.MsgSyncResp) string {
+ var changes []string
+ if len(resp.FileChanges) > 0 {
+ changes = append(changes,
+ s.formatFileChanges(resp.FileChanges))
+ }
+ if len(resp.PackageChanges) > 0 {
+ changes = append(changes,
+ s.formatPackageChanges(resp.PackageChanges))
+ }
+ if len(resp.ServiceChanges) > 0 {
+ changes = append(changes,
+ s.formatServiceChanges(resp.ServiceChanges))
+ }
+ if len(resp.CommandChanges) > 0 {
+ changes = append(changes,
+ s.formatCommandChanges(resp.CommandChanges))
+ }
+ if len(changes) == 0 {
+ // Notify user that the host was synced successfully
+ return "no changes"
+ }
+
+ 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
+}
+