diff options
author | baude <bbaude@redhat.com> | 2019-01-31 13:20:04 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-02-08 10:26:43 -0600 |
commit | 25a3923b61a5ca014318e6d957f68abd03947297 (patch) | |
tree | 2ccb4a0bd9bda70c1c258dcb1b8aca8961d9ad30 /cmd/podman/refresh.go | |
parent | 962850c6e0dfcee926af31fc0ad24f1f6c26f8ac (diff) | |
download | podman-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/refresh.go')
-rw-r--r-- | cmd/podman/refresh.go | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/cmd/podman/refresh.go b/cmd/podman/refresh.go index b07376170..3890188b4 100644 --- a/cmd/podman/refresh.go +++ b/cmd/podman/refresh.go @@ -4,37 +4,38 @@ import ( "fmt" "os" + "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/libpodruntime" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/spf13/cobra" ) var ( - refreshFlags = []cli.Flag{} - + refreshCommand cliconfig.RefreshValues refreshDescription = "The refresh command resets the state of all containers to handle database changes after a Podman upgrade. All running containers will be restarted." - - refreshCommand = cli.Command{ - Name: "refresh", - Usage: "Refresh container state", - Description: refreshDescription, - Flags: sortFlags(refreshFlags), - Action: refreshCmd, - UseShortOptionHandling: true, - OnUsageError: usageErrorHandler, + _refreshCommand = &cobra.Command{ + Use: "refresh", + Short: "Refresh container state", + Long: refreshDescription, + RunE: func(cmd *cobra.Command, args []string) error { + refreshCommand.InputArgs = args + refreshCommand.GlobalFlags = MainGlobalOpts + return refreshCmd(&refreshCommand) + }, } ) -func refreshCmd(c *cli.Context) error { - if len(c.Args()) > 0 { - return errors.Errorf("refresh does not accept any arguments") - } +func init() { + refreshCommand.Command = _refreshCommand + rootCmd.AddCommand(refreshCommand.Command) +} - if err := validateFlags(c, refreshFlags); err != nil { - return err +func refreshCmd(c *cliconfig.RefreshValues) error { + if len(c.InputArgs) > 0 { + return errors.Errorf("refresh does not accept any arguments") } - runtime, err := libpodruntime.GetRuntime(c) + runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") } |