diff options
author | Matthew Heon <mheon@redhat.com> | 2018-07-13 16:00:23 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2018-07-13 16:00:23 -0400 |
commit | 259136c36c89cb32e28edfe8b5d7a3c1082fad5b (patch) | |
tree | cf8ee1d20c0e0cb92b486be9321e5f7e4f7eb968 /cmd | |
parent | 2bdefc6c1e8795d8102bb320f3a5d7ac679cfd57 (diff) | |
download | podman-259136c36c89cb32e28edfe8b5d7a3c1082fad5b.tar.gz podman-259136c36c89cb32e28edfe8b5d7a3c1082fad5b.tar.bz2 podman-259136c36c89cb32e28edfe8b5d7a3c1082fad5b.zip |
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 <mheon@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/ps.go | 22 |
1 files changed, 8 insertions, 14 deletions
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 } |