Add a flag to print sizes and dates in human readable format.
Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
| ... | ... |
@@ -18,6 +18,7 @@ import ( |
| 18 | 18 |
// Usage: docker history [OPTIONS] IMAGE |
| 19 | 19 |
func (cli *DockerCli) CmdHistory(args ...string) error {
|
| 20 | 20 |
cmd := cli.Subcmd("history", "IMAGE", "Show the history of an image", true)
|
| 21 |
+ human := cmd.Bool([]string{"H", "-human"}, true, "Print sizes and dates in human readable format")
|
|
| 21 | 22 |
quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
|
| 22 | 23 |
noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
|
| 23 | 24 |
cmd.Require(flag.Exact, 1) |
| ... | ... |
@@ -46,14 +47,24 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
|
| 46 | 46 |
fmt.Fprintf(w, stringid.TruncateID(entry.ID)) |
| 47 | 47 |
} |
| 48 | 48 |
if !*quiet {
|
| 49 |
- if *noTrunc {
|
|
| 49 |
+ if *human {
|
|
| 50 |
+ fmt.Fprintf(w, "\t%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(entry.Created, 0)))) |
|
| 51 |
+ } else {
|
|
| 50 | 52 |
fmt.Fprintf(w, "\t%s\t", time.Unix(entry.Created, 0).Format(time.RFC3339)) |
| 53 |
+ } |
|
| 54 |
+ |
|
| 55 |
+ if *noTrunc {
|
|
| 51 | 56 |
fmt.Fprintf(w, "%s\t", entry.CreatedBy) |
| 52 | 57 |
} else {
|
| 53 |
- fmt.Fprintf(w, "\t%s ago\t", units.HumanDuration(time.Now().UTC().Sub(time.Unix(entry.Created, 0)))) |
|
| 54 | 58 |
fmt.Fprintf(w, "%s\t", stringutils.Truncate(entry.CreatedBy, 45)) |
| 55 | 59 |
} |
| 56 |
- fmt.Fprintf(w, "%s\t", units.HumanSize(float64(entry.Size))) |
|
| 60 |
+ |
|
| 61 |
+ if *human {
|
|
| 62 |
+ fmt.Fprintf(w, "%s\t", units.HumanSize(float64(entry.Size))) |
|
| 63 |
+ } else {
|
|
| 64 |
+ fmt.Fprintf(w, "%d\t", entry.Size) |
|
| 65 |
+ } |
|
| 66 |
+ |
|
| 57 | 67 |
fmt.Fprintf(w, "%s", entry.Comment) |
| 58 | 68 |
} |
| 59 | 69 |
fmt.Fprintf(w, "\n") |
| ... | ... |
@@ -19,6 +19,9 @@ Show the history of when and how an image was created. |
| 19 | 19 |
**--help** |
| 20 | 20 |
Print usage statement |
| 21 | 21 |
|
| 22 |
+**-H**. **--human**=*true*|*false* |
|
| 23 |
+ Print sizes and dates in human readable format. The default is *true*. |
|
| 24 |
+ |
|
| 22 | 25 |
**--no-trunc**=*true*|*false* |
| 23 | 26 |
Don't truncate output. The default is *false*. |
| 24 | 27 |
|
| ... | ... |
@@ -1191,6 +1191,7 @@ This will create a new Bash session in the container `ubuntu_bash`. |
| 1191 | 1191 |
|
| 1192 | 1192 |
Show the history of an image |
| 1193 | 1193 |
|
| 1194 |
+ -H, --human=true Print sizes and dates in human readable format |
|
| 1194 | 1195 |
--no-trunc=false Don't truncate output |
| 1195 | 1196 |
-q, --quiet=false Only show numeric IDs |
| 1196 | 1197 |
|