summaryrefslogtreecommitdiff
path: root/cmd/podman/system/info.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/system/info.go')
-rw-r--r--cmd/podman/system/info.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/cmd/podman/system/info.go b/cmd/podman/system/info.go
index 3e3c99488..dece6b37e 100644
--- a/cmd/podman/system/info.go
+++ b/cmd/podman/system/info.go
@@ -5,7 +5,7 @@ import (
"os"
"text/template"
- "github.com/containers/podman/v2/cmd/podman/parse"
+ "github.com/containers/common/pkg/report"
"github.com/containers/podman/v2/cmd/podman/registry"
"github.com/containers/podman/v2/cmd/podman/validate"
"github.com/containers/podman/v2/pkg/domain/entities"
@@ -20,7 +20,7 @@ var (
Useful for the user and when reporting issues.
`
infoCommand = &cobra.Command{
- Use: "info",
+ Use: "info [options]",
Args: validate.NoArgs,
Long: infoDescription,
Short: "Display podman system information",
@@ -69,26 +69,25 @@ func info(cmd *cobra.Command, args []string) error {
return err
}
- if parse.MatchesJSONFormat(inFormat) {
+ switch {
+ case report.IsJSON(inFormat):
b, err := json.MarshalIndent(info, "", " ")
if err != nil {
return err
}
fmt.Println(string(b))
- return nil
- }
- if !cmd.Flag("format").Changed {
+ case cmd.Flags().Changed("format"):
+ tmpl, err := template.New("info").Parse(inFormat)
+ if err != nil {
+ return err
+ }
+ return tmpl.Execute(os.Stdout, info)
+ default:
b, err := yaml.Marshal(info)
if err != nil {
return err
}
fmt.Println(string(b))
- return nil
- }
- tmpl, err := template.New("info").Parse(inFormat)
- if err != nil {
- return err
}
- err = tmpl.Execute(os.Stdout, info)
- return err
+ return nil
}