From fea37b387c746471177f90f15b04d7735a88e621 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Tue, 16 Oct 2018 12:04:45 +0000 Subject: Use the new checkAllAndLatest() function Instead of duplicating the same code in multiple commands this uses the newly added function checkAllAndLatest() instead. Signed-off-by: Adrian Reber --- cmd/podman/rm.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'cmd/podman/rm.go') diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go index 38b1546ff..847ea642d 100644 --- a/cmd/podman/rm.go +++ b/cmd/podman/rm.go @@ -63,13 +63,8 @@ func rmCmd(c *cli.Context) error { } defer runtime.Shutdown(false) - args := c.Args() - if c.Bool("latest") && c.Bool("all") { - return errors.Errorf("--all and --latest cannot be used together") - } - - if len(args) == 0 && !c.Bool("all") && !c.Bool("latest") { - return errors.Errorf("specify one or more containers to remove") + if err := checkAllAndLatest(c); err != nil { + return err } if c.Bool("all") { @@ -84,6 +79,7 @@ func rmCmd(c *cli.Context) error { } delContainers = append(delContainers, lastCtr) } else { + args := c.Args() for _, i := range args { container, err := runtime.LookupContainer(i) if err != nil { -- cgit v1.2.3-54-g00ecf