From 557f80e0eaef79a5846bed2140c64ec1cc455276 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Fri, 22 Mar 2013 17:22:32 -0700 Subject: [PATCH] Fancier output for 'docker history' Upstream-commit: 09b27f9e8d762713ae64711cbdfb76aa52ec1bcf Component: engine --- components/engine/commands.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/components/engine/commands.go b/components/engine/commands.go index 9716c6d3da..18ffe91403 100644 --- a/components/engine/commands.go +++ b/components/engine/commands.go @@ -330,14 +330,15 @@ func (srv *Server) CmdHistory(stdin io.ReadCloser, stdout io.Writer, args ...str if err != nil { return err } - var child *Image + w := tabwriter.NewWriter(stdout, 20, 1, 3, ' ', 0) + defer w.Flush() + fmt.Fprintf(w, "ID\tCREATED\tCREATED BY\n") return image.WalkHistory(func(img *Image) error { - if child == nil { - fmt.Fprintf(stdout, " %s\n", img.Id) - } else { - fmt.Fprintf(stdout, " = %s + %s\n", img.Id, strings.Join(child.ParentCommand, " ")) - } - child = img + fmt.Fprintf(w, "%s\t%s\t%s\n", + img.Id, + HumanDuration(time.Now().Sub(img.Created))+" ago", + strings.Join(img.ParentCommand, " "), + ) return nil }) }