Fancier output for 'docker history'

This commit is contained in:
Solomon Hykes 2013-03-22 17:22:32 -07:00
parent 5e561a9d52
commit 09b27f9e8d
1 changed files with 8 additions and 7 deletions

View File

@ -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
})
}