diff options
author | Jhon Honce <jhonce@redhat.com> | 2021-11-18 09:03:00 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2021-12-02 09:07:27 -0700 |
commit | 61792de36ea2ea98f6e3aef3821d1b15beebf9e0 (patch) | |
tree | f2e73122b2cdb0323e1d38792eef44a625b85d10 /cmd/podman/machine | |
parent | fbcebcb46a2444ce078dee10d8d51555bee8f177 (diff) | |
download | podman-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/machine')
-rw-r--r-- | cmd/podman/machine/list.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go index d569f4db0..774ab4fd0 100644 --- a/cmd/podman/machine/list.go +++ b/cmd/podman/machine/list.go @@ -116,7 +116,15 @@ func outputTemplate(cmd *cobra.Command, responses []*machineReporter) error { "DiskSize": "DISK SIZE", }) - row := report.NormalizeFormat(listFlag.format) + var row string + switch { + case cmd.Flags().Changed("format"): + row = cmd.Flag("format").Value.String() + listFlag.noHeading = !report.HasTable(row) + row = report.NormalizeFormat(row) + default: + row = cmd.Flag("format").Value.String() + } format := report.EnforceRange(row) tmpl, err := report.NewTemplate("list").Parse(format) @@ -130,10 +138,6 @@ func outputTemplate(cmd *cobra.Command, responses []*machineReporter) error { } defer w.Flush() - if cmd.Flags().Changed("format") && !report.HasTable(listFlag.format) { - listFlag.noHeading = true - } - if !listFlag.noHeading { if err := tmpl.Execute(w, headers); err != nil { return errors.Wrapf(err, "failed to write report column headers") |