summaryrefslogtreecommitdiff
path: root/cmd/podman/system
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2021-11-18 09:03:00 -0700
committerJhon Honce <jhonce@redhat.com>2021-12-02 09:07:27 -0700
commit61792de36ea2ea98f6e3aef3821d1b15beebf9e0 (patch)
treef2e73122b2cdb0323e1d38792eef44a625b85d10 /cmd/podman/system
parentfbcebcb46a2444ce078dee10d8d51555bee8f177 (diff)
downloadpodman-61792de36ea2ea98f6e3aef3821d1b15beebf9e0.tar.gz
podman-61792de36ea2ea98f6e3aef3821d1b15beebf9e0.tar.bz2
podman-61792de36ea2ea98f6e3aef3821d1b15beebf9e0.zip
Refactor podman image command output
Leverage new report.Formatter allowing better compatibility from podman command output. Follow on PR's will cover containers, etc. See #10974 Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'cmd/podman/system')
-rw-r--r--cmd/podman/system/connection/list.go9
-rw-r--r--cmd/podman/system/version.go2
2 files changed, 5 insertions, 6 deletions
diff --git a/cmd/podman/system/connection/list.go b/cmd/podman/system/connection/list.go
index f1f7657ad..2710142a8 100644
--- a/cmd/podman/system/connection/list.go
+++ b/cmd/podman/system/connection/list.go
@@ -82,7 +82,7 @@ func list(cmd *cobra.Command, _ []string) error {
return rows[i].Name < rows[j].Name
})
- format := "{{.Name}}\t{{.URI}}\t{{.Identity}}\t{{.Default}}\n"
+ var format string
switch {
case report.IsJSON(cmd.Flag("format").Value.String()):
buf, err := registry.JSONLibrary().MarshalIndent(rows, "", " ")
@@ -90,11 +90,10 @@ func list(cmd *cobra.Command, _ []string) error {
fmt.Println(string(buf))
}
return err
+ case cmd.Flags().Changed("format"):
+ format = report.NormalizeFormat(cmd.Flag("format").Value.String())
default:
- if cmd.Flag("format").Changed {
- format = cmd.Flag("format").Value.String()
- format = report.NormalizeFormat(format)
- }
+ format = "{{.Name}}\t{{.URI}}\t{{.Identity}}\t{{.Default}}\n"
}
format = report.EnforceRange(format)
diff --git a/cmd/podman/system/version.go b/cmd/podman/system/version.go
index 3443978d6..87b806503 100644
--- a/cmd/podman/system/version.go
+++ b/cmd/podman/system/version.go
@@ -59,7 +59,7 @@ func version(cmd *cobra.Command, args []string) error {
}
defer w.Flush()
- if cmd.Flag("format").Changed {
+ if cmd.Flags().Changed("format") {
row := report.NormalizeFormat(versionFormat)
tmpl, err := report.NewTemplate("version 2.0.0").Parse(row)
if err != nil {