Convert CLI to urfave v2
Followed the Migration Guide at https://cli.urfave.org/migrate-v1-to-v2/ The major changes not pointed out in the migration guide are: - context.Args() no longer produces a []slice, so context.Args().Slice() in substitued - All cli.Global***** are deprecated (the migration guide is somewhat unclear on this) Signed-off-by: Derek Nola <derek.nola@suse.com> Vendor in urfave cli/v2 Signed-off-by: Derek Nola <derek.nola@suse.com> Fix NewStringSlice calls Signed-off-by: Derek Nola <derek.nola@suse.com>
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
||||
"github.com/containerd/console"
|
||||
gocni "github.com/containerd/go-cni"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/urfave/cli"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
containerd "github.com/containerd/containerd/v2/client"
|
||||
"github.com/containerd/containerd/v2/cmd/ctr/commands"
|
||||
@@ -89,41 +89,41 @@ func parseMountFlag(m string) (specs.Mount, error) {
|
||||
}
|
||||
|
||||
// Command runs a container
|
||||
var Command = cli.Command{
|
||||
Name: "run",
|
||||
Usage: "Run a container",
|
||||
ArgsUsage: "[flags] Image|RootFS ID [COMMAND] [ARG...]",
|
||||
SkipArgReorder: true,
|
||||
var Command = &cli.Command{
|
||||
Name: "run",
|
||||
Usage: "Run a container",
|
||||
ArgsUsage: "[flags] Image|RootFS ID [COMMAND] [ARG...]",
|
||||
Flags: append([]cli.Flag{
|
||||
cli.BoolFlag{
|
||||
&cli.BoolFlag{
|
||||
Name: "rm",
|
||||
Usage: "Remove the container after running, cannot be used with --detach",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
&cli.BoolFlag{
|
||||
Name: "null-io",
|
||||
Usage: "Send all IO to /dev/null",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "log-uri",
|
||||
Usage: "Log uri",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "detach,d",
|
||||
Usage: "Detach from the task after it has started execution, cannot be used with --rm",
|
||||
&cli.BoolFlag{
|
||||
Name: "detach",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Detach from the task after it has started execution, cannot be used with --rm",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "fifo-dir",
|
||||
Usage: "Directory used for storing IO FIFOs",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "cgroup",
|
||||
Usage: "Cgroup path (To disable use of cgroup, set to \"\" explicitly)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
&cli.StringFlag{
|
||||
Name: "platform",
|
||||
Usage: "Run image for specific platform",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
&cli.BoolFlag{
|
||||
Name: "cni",
|
||||
Usage: "Enable cni networking for the container",
|
||||
},
|
||||
@@ -259,7 +259,7 @@ var Command = cli.Command{
|
||||
return err
|
||||
}
|
||||
if code != 0 {
|
||||
return cli.NewExitError("", int(code))
|
||||
return cli.Exit("", int(code))
|
||||
}
|
||||
return nil
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user