aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/unpause.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-01-31 13:20:04 -0600
committerbaude <bbaude@redhat.com>2019-02-08 10:26:43 -0600
commit25a3923b61a5ca014318e6d957f68abd03947297 (patch)
tree2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/unpause.go
parent962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff)
downloadpodman-25a3923b61a5ca014318e6d957f68abd03947297.tar.gz
podman-25a3923b61a5ca014318e6d957f68abd03947297.tar.bz2
podman-25a3923b61a5ca014318e6d957f68abd03947297.zip
Migrate to cobra CLI
We intend to migrate to the cobra cli from urfave/cli because the project is more well maintained. There are also some technical reasons as well which extend into our remote client work. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/unpause.go')
-rw-r--r--cmd/podman/unpause.go51
1 files changed, 29 insertions, 22 deletions
diff --git a/cmd/podman/unpause.go b/cmd/podman/unpause.go
index 91b5fda33..fb3a7b57a 100644
--- a/cmd/podman/unpause.go
+++ b/cmd/podman/unpause.go
@@ -3,38 +3,45 @@ package main
import (
"os"
+ "github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- "github.com/urfave/cli"
+ "github.com/spf13/cobra"
)
var (
- unpauseFlags = []cli.Flag{
- cli.BoolFlag{
- Name: "all, a",
- Usage: "Unpause all paused containers",
- },
- }
+ unpauseCommand cliconfig.UnpauseValues
+
unpauseDescription = `
podman unpause
Unpauses one or more running containers. The container name or ID can be used.
`
- unpauseCommand = cli.Command{
- Name: "unpause",
- Usage: "Unpause the processes in one or more containers",
- Description: unpauseDescription,
- Flags: unpauseFlags,
- Action: unpauseCmd,
- ArgsUsage: "CONTAINER-NAME [CONTAINER-NAME ...]",
- OnUsageError: usageErrorHandler,
+ _unpauseCommand = &cobra.Command{
+ Use: "unpause",
+ Short: "Unpause the processes in one or more containers",
+ Long: unpauseDescription,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ unpauseCommand.InputArgs = args
+ unpauseCommand.GlobalFlags = MainGlobalOpts
+ return unpauseCmd(&unpauseCommand)
+ },
+ Example: "CONTAINER-NAME [CONTAINER-NAME ...]",
}
)
-func unpauseCmd(c *cli.Context) error {
+func init() {
+ unpauseCommand.Command = _unpauseCommand
+ flags := unpauseCommand.Flags()
+ flags.BoolVarP(&unpauseCommand.All, "all", "a", false, "Unpause all paused containers")
+
+ rootCmd.AddCommand(unpauseCommand.Command)
+}
+
+func unpauseCmd(c *cliconfig.UnpauseValues) error {
var (
unpauseContainers []*libpod.Container
unpauseFuncs []shared.ParallelWorkerInput
@@ -43,18 +50,18 @@ func unpauseCmd(c *cli.Context) error {
return errors.New("unpause is not supported for rootless containers")
}
- runtime, err := libpodruntime.GetRuntime(c)
+ runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
- args := c.Args()
- if len(args) < 1 && !c.Bool("all") {
+ args := c.InputArgs
+ if len(args) < 1 && !c.All {
return errors.Errorf("you must provide at least one container name or id")
}
- if c.Bool("all") {
- cs, err := getAllOrLatestContainers(c, runtime, libpod.ContainerStatePaused, "paused")
+ if c.All {
+ cs, err := getAllOrLatestContainers(&c.PodmanCommand, runtime, libpod.ContainerStatePaused, "paused")
if err != nil {
return err
}
@@ -84,7 +91,7 @@ func unpauseCmd(c *cli.Context) error {
maxWorkers := shared.Parallelize("unpause")
if c.GlobalIsSet("max-workers") {
- maxWorkers = c.GlobalInt("max-workers")
+ maxWorkers = c.GlobalFlags.MaxWorks
}
logrus.Debugf("Setting maximum workers to %d", maxWorkers)