mirror of
https://github.com/containers/podman.git
synced 2025-06-19 00:06:43 +08:00
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>
This commit is contained in:
@ -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") || 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 c.Bool("size") {
|
||||
flags++
|
||||
}
|
||||
if c.Bool("namespace") {
|
||||
flags++
|
||||
}
|
||||
if c.IsSet("format") && c.String("format") != formats.JSONString {
|
||||
flags++
|
||||
}
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user