summaryrefslogtreecommitdiff
path: root/cmd/podman/stop.go
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2018-10-16 12:04:45 +0000
committerAdrian Reber <adrian@lisas.de>2018-10-23 17:01:30 +0200
commitfea37b387c746471177f90f15b04d7735a88e621 (patch)
tree77b4bf6ae101c001ed543e44daa7b5cbec497404 /cmd/podman/stop.go
parent215cf7b8984f687a79ce6055e350ee3e75d81b79 (diff)
downloadpodman-fea37b387c746471177f90f15b04d7735a88e621.tar.gz
podman-fea37b387c746471177f90f15b04d7735a88e621.tar.bz2
podman-fea37b387c746471177f90f15b04d7735a88e621.zip
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 <areber@redhat.com>
Diffstat (limited to 'cmd/podman/stop.go')
-rw-r--r--cmd/podman/stop.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go
index ff0b36bf1..f5c0fca85 100644
--- a/cmd/podman/stop.go
+++ b/cmd/podman/stop.go
@@ -44,16 +44,11 @@ var (
)
func stopCmd(c *cli.Context) error {
- args := c.Args()
- if (c.Bool("all") || c.Bool("latest")) && len(args) > 0 {
- return errors.Errorf("no arguments are needed with --all or --latest")
- }
- if c.Bool("all") && c.Bool("latest") {
- return errors.Errorf("--all and --latest cannot be used together")
- }
- if len(args) < 1 && !c.Bool("all") && !c.Bool("latest") {
- return errors.Errorf("you must provide at least one container name or id")
+
+ if err := checkAllAndLatest(c); err != nil {
+ return err
}
+
if err := validateFlags(c, stopFlags); err != nil {
return err
}
@@ -86,6 +81,7 @@ func stopCmd(c *cli.Context) error {
}
containers = append(containers, lastCtr)
} else {
+ args := c.Args()
for _, i := range args {
container, err := runtime.LookupContainer(i)
if err != nil {