Fix displayJson behavior (dont add newline)

This commit is contained in:
Guillaume J. Charmes 2013-12-02 11:47:13 -08:00
parent de4429f70d
commit 6ea3b9651b
No known key found for this signature in database
GPG key ID: B33E4642CB6E3FF3
2 changed files with 4 additions and 2 deletions

View file

@ -228,6 +228,8 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
if context != nil {
headers.Set("Content-Type", "application/tar")
}
// Temporary hack to fix displayJSON behavior
cli.isTerminal = false
err = cli.stream("POST", fmt.Sprintf("/build?%s", v.Encode()), body, cli.out, headers)
if jerr, ok := err.(*utils.JSONError); ok {
return &utils.StatusError{Status: jerr.Message, StatusCode: jerr.Code}

View file

@ -63,7 +63,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
if isTerminal {
// <ESC>[2K = erase entire current line
fmt.Fprintf(out, "%c[2K\r", 27)
endl = "\r"
endl = "\r\n"
}
if jm.Time != 0 {
fmt.Fprintf(out, "[%s] ", time.Unix(jm.Time, 0))
@ -79,7 +79,7 @@ func (jm *JSONMessage) Display(out io.Writer, isTerminal bool) error {
} else if jm.ProgressMessage != "" { //deprecated
fmt.Fprintf(out, "%s %s%s", jm.Status, jm.ProgressMessage, endl)
} else {
fmt.Fprintf(out, "%s%s\n", jm.Status, endl)
fmt.Fprintf(out, "%s%s", jm.Status, endl)
}
return nil
}