Browse code

print everything except progress in non-terminal

Instead of only checking `Progress != nil` (which is always true because
the server sends `"progressDetail":{}` when it doesnt have the progress), we
also check if `Progress.String() != ""`, which should be sufficient to filter
out the progress data.

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)

Daniel, Dao Quang Minh authored on 2014/09/24 16:26:53
Showing 1 changed files
... ...
@@ -97,7 +97,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
97 97
 		// <ESC>[2K = erase entire current line
98 98
 		fmt.Fprintf(out, "%c[2K\r", 27)
99 99
 		endl = "\r"
100
-	} else if jm.Progress != nil { //disable progressbar in non-terminal
100
+	} else if jm.Progress != nil && jm.Progress.String() != "" { //disable progressbar in non-terminal
101 101
 		return nil
102 102
 	}
103 103
 	if jm.Time != 0 {
... ...
@@ -109,7 +109,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
109 109
 	if jm.From != "" {
110 110
 		fmt.Fprintf(out, "(from %s) ", jm.From)
111 111
 	}
112
-	if jm.Progress != nil {
112
+	if jm.Progress != nil && isTerminal {
113 113
 		fmt.Fprintf(out, "%s %s%s", jm.Status, jm.Progress.String(), endl)
114 114
 	} else if jm.ProgressMessage != "" { //deprecated
115 115
 		fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)