diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2022-01-11 06:36:45 -0500 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2022-01-11 06:36:45 -0500 |
commit | c085fb3c9792df9d6756eb4995c428dfd4813a60 (patch) | |
tree | 193f1deba9bbca4c907a600b3e9196cb7c8741fe | |
parent | ed9ef59e7ea439b670875863132b68fd094501c7 (diff) | |
download | podman-c085fb3c9792df9d6756eb4995c428dfd4813a60.tar.gz podman-c085fb3c9792df9d6756eb4995c428dfd4813a60.tar.bz2 podman-c085fb3c9792df9d6756eb4995c428dfd4813a60.zip |
Pretty Print output of podman machine ls --format json
Make JSON more prominent in podman machine ls --help and man page.
[NO NEW TESTS NEEDED]
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r-- | cmd/podman/machine/list.go | 3 | ||||
-rw-r--r-- | docs/source/markdown/podman-machine-list.1.md | 39 |
2 files changed, 35 insertions, 7 deletions
diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go index 858d87401..ed43b42df 100644 --- a/cmd/podman/machine/list.go +++ b/cmd/podman/machine/list.go @@ -32,6 +32,7 @@ var ( Args: validate.NoArgs, ValidArgsFunction: completion.AutocompleteNone, Example: `podman machine list, + podman machine list --format json podman machine ls`, } listFlag = listFlagType{} @@ -96,7 +97,7 @@ func list(cmd *cobra.Command, args []string) error { return err } - b, err := json.Marshal(machineReporter) + b, err := json.MarshalIndent(machineReporter, "", " ") if err != nil { return err } diff --git a/docs/source/markdown/podman-machine-list.1.md b/docs/source/markdown/podman-machine-list.1.md index accdd760c..b2596ac59 100644 --- a/docs/source/markdown/podman-machine-list.1.md +++ b/docs/source/markdown/podman-machine-list.1.md @@ -20,16 +20,23 @@ tied to the Linux kernel. #### **--format**=*format* -Format list output using a Go template. - +Change the default output format. This can be of a supported type like 'json' +or a Go template. Valid placeholders for the Go template are listed below: | **Placeholder** | **Description** | | --------------- | ------------------------------- | -| .Name | VM name | +| .CPUs | Number of CPUs | | .Created | Time since VM creation | +| .Default | Is default machine | +| .DiskSize | Disk size of machine | +| .LastUp | Time machine was last up | | .LastUp | Time since the VM was last run | -| .VMType | VM type | +| .Memory | Allocated memeory for machine | +| .Name | VM name | +| .Running | Is machine running | +| .Stream | Stream name | +| .VMType | VM type | #### **--help** @@ -43,8 +50,28 @@ Omit the table headings from the listing of pods. ``` $ podman machine list - -$ podman machine ls --format {{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}\n +NAME VM TYPE CREATED LAST UP CPUS MEMORY DISK SIZE +podman-machine-default qemu 2 weeks ago 2 weeks ago 1 2.147GB 10.74GB + +$ podman machine ls --format "table {{.Name}}\t{{.VMType}}\t{{.Created}}\t{{.LastUp}}" +NAME VM TYPE CREATED LAST UP +podman-machine-default qemu 2 weeks ago 2 weeks ago + +$ podman machine ls --format json +[ + { + "Name": "podman-machine-default", + "Default": false, + "Created": "2021-12-27T10:36:14.373347492-05:00", + "Running": false, + "LastUp": "2021-12-27T11:22:50.17333371-05:00", + "Stream": "default", + "VMType": "qemu", + "CPUs": 1, + "Memory": "2147483648", + "DiskSize": "10737418240" + } +] ``` ## SEE ALSO |