diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-08 20:12:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-08 20:12:38 +0100 |
commit | afd4d5f4a4b05f421e6f336b4d74a0d808be57ed (patch) | |
tree | 2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/pod_inspect.go | |
parent | 962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff) | |
parent | 25a3923b61a5ca014318e6d957f68abd03947297 (diff) | |
download | podman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.tar.gz podman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.tar.bz2 podman-afd4d5f4a4b05f421e6f336b4d74a0d808be57ed.zip |
Merge pull request #2274 from baude/cobraprep
Migrate to cobra CLI
Diffstat (limited to 'cmd/podman/pod_inspect.go')
-rw-r--r-- | cmd/podman/pod_inspect.go | 45 |
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") |