From b96887bcaa78e1072ccc1a06e57abafaed0a6bc6 Mon Sep 17 00:00:00 2001 From: umohnani8 Date: Fri, 26 Jan 2018 10:29:12 -0500 Subject: Fix tab issue with --format flag When the Go template was given with \t in between fields, the \t was not being recognized as a tab. Fixes that issue. Signed-off-by: umohnani8 Closes: #265 Approved by: rhatdan --- cmd/podman/stats.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/stats.go b/cmd/podman/stats.go index 21cca1d83..3c2dfb5cf 100644 --- a/cmd/podman/stats.go +++ b/cmd/podman/stats.go @@ -89,16 +89,9 @@ func statsCmd(c *cli.Context) error { times = 1 } - var format string var ctrs []*libpod.Container var containerFunc func() ([]*libpod.Container, error) - if c.IsSet("format") { - format = c.String("format") - } else { - format = genStatsFormat() - } - containerFunc = runtime.GetRunningContainers if len(c.Args()) > 0 { containerFunc = func() ([]*libpod.Container, error) { return runtime.GetContainersByList(c.Args()) } @@ -127,6 +120,9 @@ func statsCmd(c *cli.Context) error { } containerStats[ctr.ID()] = initialStats } + + format := genStatsFormat(c.String("format")) + step := 1 if times == -1 { times = 1 @@ -183,7 +179,7 @@ func outputStats(stats []*libpod.ContainerStats, format string) error { return formats.Writer(out).Out() } -func genStatsFormat() (format string) { +func genStatsFormat(format string) string { if format != "" { // "\t" from the command line is not being recognized as a tab // replacing the string "\t" to a tab character if the user passes in "\t" -- cgit v1.2.3-54-g00ecf