summaryrefslogtreecommitdiff
path: root/cmd/podman/images/history.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/images/history.go')
-rw-r--r--cmd/podman/images/history.go41
1 files changed, 29 insertions, 12 deletions
diff --git a/cmd/podman/images/history.go b/cmd/podman/images/history.go
index b8d216cc1..17a80557e 100644
--- a/cmd/podman/images/history.go
+++ b/cmd/podman/images/history.go
@@ -15,6 +15,7 @@ import (
"github.com/docker/go-units"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -32,6 +33,15 @@ var (
RunE: history,
}
+ imageHistoryCmd = &cobra.Command{
+ Args: historyCmd.Args,
+ Use: historyCmd.Use,
+ Short: historyCmd.Short,
+ Long: historyCmd.Long,
+ RunE: historyCmd.RunE,
+ Example: `podman image history imageID`,
+ }
+
opts = struct {
human bool
noTrunc bool
@@ -45,8 +55,17 @@ func init() {
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
Command: historyCmd,
})
+ historyFlags(historyCmd.Flags())
- flags := historyCmd.Flags()
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
+ Command: imageHistoryCmd,
+ Parent: imageCmd,
+ })
+ historyFlags(imageHistoryCmd.Flags())
+}
+
+func historyFlags(flags *pflag.FlagSet) {
flags.StringVar(&opts.format, "format", "", "Change the output to JSON or a Go template")
flags.BoolVarP(&opts.human, "human", "H", true, "Display sizes and dates in human readable format")
flags.BoolVar(&opts.noTrunc, "no-trunc", false, "Do not truncate the output")
@@ -89,22 +108,20 @@ func history(cmd *cobra.Command, args []string) error {
hdr := "ID\tCREATED\tCREATED BY\tSIZE\tCOMMENT\n"
row := "{{.ID}}\t{{.Created}}\t{{.CreatedBy}}\t{{.Size}}\t{{.Comment}}\n"
- if len(opts.format) > 0 {
+ switch {
+ case len(opts.format) > 0:
hdr = ""
row = opts.format
if !strings.HasSuffix(opts.format, "\n") {
row += "\n"
}
- } else {
- switch {
- case opts.human:
- row = "{{.ID}}\t{{.Created}}\t{{.CreatedBy}}\t{{.Size}}\t{{.Comment}}\n"
- case opts.noTrunc:
- row = "{{.ID}}\t{{.Created}}\t{{.CreatedBy}}\t{{.Size}}\t{{.Comment}}\n"
- case opts.quiet:
- hdr = ""
- row = "{{.ID}}\n"
- }
+ case opts.quiet:
+ hdr = ""
+ row = "{{.ID}}\n"
+ case opts.human:
+ row = "{{.ID}}\t{{.Created}}\t{{.CreatedBy}}\t{{.Size}}\t{{.Comment}}\n"
+ case opts.noTrunc:
+ row = "{{.ID}}\t{{.Created}}\t{{.CreatedBy}}\t{{.Size}}\t{{.Comment}}\n"
}
format := hdr + "{{range . }}" + row + "{{end}}"