From 259136c36c89cb32e28edfe8b5d7a3c1082fad5b Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 13 Jul 2018 16:00:23 -0400 Subject: Change logic for detecting conflicting flags in ps There's no reason --size cannot be used together with a Go template - in fact, using a Go template for {{.Size}} without --size being passed will not work. Allow use of --namespace and --size with Go templates, but not with --quiet. Do not allow --namespace and --size at the same time. Signed-off-by: Matthew Heon --- cmd/podman/ps.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index 921490ba9..8cec73b3c 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -282,22 +282,16 @@ func checkFlagsPassed(c *cli.Context) error { if c.Int("last") >= 0 && c.Bool("latest") { return errors.Errorf("last and latest are mutually exclusive") } - // quiet, size, namespace, and format with Go template are mutually exclusive - flags := 0 + // Quiet conflicts with size, namespace, and format with a Go template if c.Bool("quiet") { - flags++ - } - if c.Bool("size") { - flags++ - } - if c.Bool("namespace") { - flags++ - } - if c.IsSet("format") && c.String("format") != formats.JSONString { - flags++ + if c.Bool("size") || c.Bool("namespace") || (c.IsSet("format") && + c.String("format") != formats.JSONString) { + return errors.Errorf("quiet conflicts with size, namespace, and format with go template") + } } - if flags > 1 { - return errors.Errorf("quiet, size, namespace, and format with Go template are mutually exclusive") + // Size and namespace conflict with each other + if c.Bool("size") && c.Bool("namespace") { + return errors.Errorf("size and namespace options conflict") } return nil } -- cgit v1.2.3-54-g00ecf