if len(changes) == 0 {
return ""
}
- 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 {