diff --git a/cmd/kpod/main.go b/cmd/kpod/main.go index 65961c5f..13f71cd2 100644 --- a/cmd/kpod/main.go +++ b/cmd/kpod/main.go @@ -105,7 +105,7 @@ func main() { if debug { logrus.Errorf(err.Error()) } else { - fmt.Println(err.Error()) + fmt.Fprintln(os.Stderr, err.Error()) } cli.OsExiter(1) } diff --git a/cmd/kpod/stop.go b/cmd/kpod/stop.go index 93eed6f3..49ef483c 100644 --- a/cmd/kpod/stop.go +++ b/cmd/kpod/stop.go @@ -2,11 +2,11 @@ package main import ( "fmt" + "os" + "github.com/kubernetes-incubator/cri-o/libkpod" "github.com/pkg/errors" - "github.com/sirupsen/logrus" "github.com/urfave/cli" - "os" ) var ( @@ -18,15 +18,21 @@ var ( Value: defaultTimeout, }, } - stopDescription = "Stop one or more containers" - stopCommand = cli.Command{ - Name: "stop", - Usage: "Stops one or more running containers. The container name or ID can be used. A timeout to forcibly" + - " stop the container can also be set but defaults to 10 seconds otherwise.", + stopDescription = ` + kpod stop + + Stops one or more running containers. The container name or ID can be used. + A timeout to forcibly stop the container can also be set but defaults to 10 + seconds otherwise. +` + + stopCommand = cli.Command{ + Name: "stop", + Usage: "Stop one or more containers", Description: stopDescription, Flags: stopFlags, Action: stopCmd, - ArgsUsage: "CONTAINER-NAME", + ArgsUsage: "CONTAINER-NAME [CONTAINER-NAME ...]", } ) @@ -50,19 +56,18 @@ func stopCmd(c *cli.Context) error { if err != nil { return errors.Wrapf(err, "could not update list of containers") } - hadError := false + var lastError error for _, container := range c.Args() { cid, err := server.ContainerStop(container, stopTimeout) if err != nil { - hadError = true - logrus.Error(err) + if lastError != nil { + fmt.Fprintln(os.Stderr, lastError) + } + lastError = errors.Wrapf(err, "failed to stop container %v", container) } else { fmt.Println(cid) } } - if hadError { - os.Exit(1) - } - return nil + return lastError }