From 25a3923b61a5ca014318e6d957f68abd03947297 Mon Sep 17 00:00:00 2001 From: baude Date: Thu, 31 Jan 2019 13:20:04 -0600 Subject: 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 --- cmd/podman/tag.go | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'cmd/podman/tag.go') diff --git a/cmd/podman/tag.go b/cmd/podman/tag.go index d19cf69a2..2c7cf4abb 100644 --- a/cmd/podman/tag.go +++ b/cmd/podman/tag.go @@ -1,29 +1,41 @@ package main import ( + "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/libpod/adapter" "github.com/pkg/errors" - "github.com/urfave/cli" + "github.com/spf13/cobra" ) var ( + tagCommand cliconfig.TagValues + tagDescription = "Adds one or more additional names to locally-stored image" - tagCommand = cli.Command{ - Name: "tag", - Usage: "Add an additional name to a local image", - Description: tagDescription, - Action: tagCmd, - ArgsUsage: "IMAGE-NAME [IMAGE-NAME ...]", - OnUsageError: usageErrorHandler, + _tagCommand = &cobra.Command{ + Use: "tag", + Short: "Add an additional name to a local image", + Long: tagDescription, + RunE: func(cmd *cobra.Command, args []string) error { + tagCommand.InputArgs = args + tagCommand.GlobalFlags = MainGlobalOpts + return tagCmd(&tagCommand) + }, + Example: "IMAGE-NAME [IMAGE-NAME ...]", } ) -func tagCmd(c *cli.Context) error { - args := c.Args() +func init() { + tagCommand.Command = _tagCommand + rootCmd.AddCommand(tagCommand.Command) + +} + +func tagCmd(c *cliconfig.TagValues) error { + args := c.InputArgs if len(args) < 2 { return errors.Errorf("image name and at least one new name must be specified") } - runtime, err := adapter.GetRuntime(c) + runtime, err := adapter.GetRuntime(&c.PodmanCommand) if err != nil { return errors.Wrapf(err, "could not create runtime") } -- cgit v1.2.3-54-g00ecf