summaryrefslogtreecommitdiff
path: root/cmd/podman/pod_inspect.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/pod_inspect.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/pod_inspect.go')
-rw-r--r--cmd/podman/pod_inspect.go45
1 files changed, 26 insertions, 19 deletions
diff --git a/cmd/podman/pod_inspect.go b/cmd/podman/pod_inspect.go
index c7bbf31cd..f4c357e96 100644
--- a/cmd/podman/pod_inspect.go
+++ b/cmd/podman/pod_inspect.go
@@ -2,46 +2,53 @@ package main
import (
"encoding/json"
-
"fmt"
+
+ "github.com/containers/libpod/cmd/podman/cliconfig"
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
"github.com/pkg/errors"
- "github.com/urfave/cli"
+ "github.com/spf13/cobra"
)
var (
- podInspectFlags = []cli.Flag{
- LatestPodFlag,
- }
+ podInspectCommand cliconfig.PodInspectValues
podInspectDescription = "Display the configuration for a pod by name or id"
- podInspectCommand = cli.Command{
- Name: "inspect",
- Usage: "Displays a pod configuration",
- Description: podInspectDescription,
- Flags: sortFlags(podInspectFlags),
- Action: podInspectCmd,
- UseShortOptionHandling: true,
- ArgsUsage: "[POD_NAME_OR_ID]",
- OnUsageError: usageErrorHandler,
+ _podInspectCommand = &cobra.Command{
+ Use: "inspect",
+ Short: "Displays a pod configuration",
+ Long: podInspectDescription,
+ RunE: func(cmd *cobra.Command, args []string) error {
+ podInspectCommand.InputArgs = args
+ podInspectCommand.GlobalFlags = MainGlobalOpts
+ return podInspectCmd(&podInspectCommand)
+ },
+ Example: "[POD_NAME_OR_ID]",
}
)
-func podInspectCmd(c *cli.Context) error {
+func init() {
+ podInspectCommand.Command = _podInspectCommand
+ flags := podInspectCommand.Flags()
+ flags.BoolVarP(&podInspectCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
+
+}
+
+func podInspectCmd(c *cliconfig.PodInspectValues) error {
var (
pod *libpod.Pod
)
- if err := checkMutuallyExclusiveFlags(c); err != nil {
+ if err := checkMutuallyExclusiveFlags(&c.PodmanCommand); err != nil {
return err
}
- args := c.Args()
- runtime, err := libpodruntime.GetRuntime(c)
+ args := c.InputArgs
+ runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand)
if err != nil {
return errors.Wrapf(err, "could not get runtime")
}
defer runtime.Shutdown(false)
- if c.Bool("latest") {
+ if c.Latest {
pod, err = runtime.GetLatestPod()
if err != nil {
return errors.Wrapf(err, "unable to get latest pod")