Skip to content

Commit ed19775

Browse files
authored
Merge pull request #306 from vrothberg/fix-args-parsing
crictl-exec: fix argument parsing
2 parents 401be60 + 0ed0c39 commit ed19775

20 files changed

+615
-350
lines changed

cmd/crictl/attach.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ import (
3131
)
3232

3333
var runtimeAttachCommand = cli.Command{
34-
Name: "attach",
35-
Usage: "Attach to a running container",
36-
ArgsUsage: "CONTAINER",
34+
Name: "attach",
35+
Usage: "Attach to a running container",
36+
ArgsUsage: "CONTAINER",
37+
SkipArgReorder: true,
38+
UseShortOptionHandling: true,
3739
Flags: []cli.Flag{
3840
cli.BoolFlag{
3941
Name: "tty,t",

cmd/crictl/config.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ func writeConfig(c *Config, filepath string) error {
6060
}
6161

6262
var configCommand = cli.Command{
63-
Name: "config",
64-
Usage: "Get and set crictl options",
65-
ArgsUsage: "[<options>]",
63+
Name: "config",
64+
Usage: "Get and set crictl options",
65+
ArgsUsage: "[<options>]",
66+
SkipArgReorder: true,
67+
UseShortOptionHandling: true,
6668
Flags: []cli.Flag{
6769
cli.StringFlag{
6870
Name: "get",

cmd/crictl/container.go

+10-5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ var createContainerCommand = cli.Command{
5555
Usage: "Create a new container",
5656
ArgsUsage: "POD container-config.[json|yaml] pod-config.[json|yaml]",
5757
Flags: []cli.Flag{},
58+
5859
Action: func(context *cli.Context) error {
5960
if len(context.Args()) != 3 {
6061
return cli.ShowSubcommandHelp(context)
@@ -160,9 +161,11 @@ var updateContainerCommand = cli.Command{
160161
}
161162

162163
var stopContainerCommand = cli.Command{
163-
Name: "stop",
164-
Usage: "Stop one or more running containers",
165-
ArgsUsage: "CONTAINER [CONTAINER...]",
164+
Name: "stop",
165+
Usage: "Stop one or more running containers",
166+
ArgsUsage: "CONTAINER [CONTAINER...]",
167+
SkipArgReorder: true,
168+
UseShortOptionHandling: true,
166169
Flags: []cli.Flag{
167170
cli.Int64Flag{
168171
Name: "timeout, t",
@@ -246,8 +249,10 @@ var containerStatusCommand = cli.Command{
246249
}
247250

248251
var listContainersCommand = cli.Command{
249-
Name: "ps",
250-
Usage: "List containers",
252+
Name: "ps",
253+
Usage: "List containers",
254+
SkipArgReorder: true,
255+
UseShortOptionHandling: true,
251256
Flags: []cli.Flag{
252257
cli.BoolFlag{
253258
Name: "verbose, v",

cmd/crictl/exec.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ const (
3636
)
3737

3838
var runtimeExecCommand = cli.Command{
39-
Name: "exec",
40-
Usage: "Run a command in a running container",
41-
ArgsUsage: "CONTAINER COMMAND [ARG...]",
39+
Name: "exec",
40+
Usage: "Run a command in a running container",
41+
ArgsUsage: "CONTAINER COMMAND [ARG...]",
42+
SkipArgReorder: true,
43+
UseShortOptionHandling: true,
4244
Flags: []cli.Flag{
4345
cli.BoolFlag{
4446
Name: "sync, s",

cmd/crictl/image.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ func (a imageByRef) Less(i, j int) bool {
4646
}
4747

4848
var pullImageCommand = cli.Command{
49-
Name: "pull",
50-
Usage: "Pull an image from a registry",
49+
Name: "pull",
50+
Usage: "Pull an image from a registry",
51+
SkipArgReorder: true,
52+
UseShortOptionHandling: true,
5153
Flags: []cli.Flag{
5254
cli.StringFlag{
5355
Name: "creds",
@@ -85,9 +87,11 @@ var pullImageCommand = cli.Command{
8587
}
8688

8789
var listImageCommand = cli.Command{
88-
Name: "images",
89-
Usage: "List images",
90-
ArgsUsage: "[REPOSITORY[:TAG]]",
90+
Name: "images",
91+
Usage: "List images",
92+
ArgsUsage: "[REPOSITORY[:TAG]]",
93+
SkipArgReorder: true,
94+
UseShortOptionHandling: true,
9195
Flags: []cli.Flag{
9296
cli.BoolFlag{
9397
Name: "verbose, v",
@@ -189,9 +193,11 @@ var listImageCommand = cli.Command{
189193
}
190194

191195
var imageStatusCommand = cli.Command{
192-
Name: "inspecti",
193-
Usage: "Return the status of one ore more images",
194-
ArgsUsage: "IMAGEID [IMAGEID...]",
196+
Name: "inspecti",
197+
Usage: "Return the status of one ore more images",
198+
ArgsUsage: "IMAGEID [IMAGEID...]",
199+
SkipArgReorder: true,
200+
UseShortOptionHandling: true,
195201
Flags: []cli.Flag{
196202
cli.StringFlag{
197203
Name: "output, o",

cmd/crictl/info.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ import (
2626
)
2727

2828
var runtimeStatusCommand = cli.Command{
29-
Name: "info",
30-
Usage: "Display information of the container runtime",
31-
ArgsUsage: "",
29+
Name: "info",
30+
Usage: "Display information of the container runtime",
31+
ArgsUsage: "",
32+
SkipArgReorder: true,
33+
UseShortOptionHandling: true,
3234
Flags: []cli.Flag{
3335
cli.StringFlag{
3436
Name: "output, o",

cmd/crictl/logs.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ import (
2929
)
3030

3131
var logsCommand = cli.Command{
32-
Name: "logs",
33-
Usage: "Fetch the logs of a container",
34-
ArgsUsage: "CONTAINER",
32+
Name: "logs",
33+
Usage: "Fetch the logs of a container",
34+
ArgsUsage: "CONTAINER",
35+
SkipArgReorder: true,
36+
UseShortOptionHandling: true,
3537
Flags: []cli.Flag{
3638
cli.BoolFlag{
3739
Name: "follow, f",

cmd/crictl/sandbox.go

+9-5
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ var removePodCommand = cli.Command{
115115
}
116116

117117
var podStatusCommand = cli.Command{
118-
Name: "inspectp",
119-
Usage: "Display the status of one or more pods",
120-
ArgsUsage: "POD [POD...]",
118+
Name: "inspectp",
119+
Usage: "Display the status of one or more pods",
120+
ArgsUsage: "POD [POD...]",
121+
SkipArgReorder: true,
122+
UseShortOptionHandling: true,
121123
Flags: []cli.Flag{
122124
cli.StringFlag{
123125
Name: "output, o",
@@ -148,8 +150,10 @@ var podStatusCommand = cli.Command{
148150
}
149151

150152
var listPodCommand = cli.Command{
151-
Name: "pods",
152-
Usage: "List pods",
153+
Name: "pods",
154+
Usage: "List pods",
155+
SkipArgReorder: true,
156+
UseShortOptionHandling: true,
153157
Flags: []cli.Flag{
154158
cli.StringFlag{
155159
Name: "id",

cmd/crictl/stats.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ type statsOptions struct {
4949
var statsCommand = cli.Command{
5050
Name: "stats",
5151
// TODO(random-liu): Support live monitoring of resource usage.
52-
Usage: "List container(s) resource usage statistics",
52+
Usage: "List container(s) resource usage statistics",
53+
SkipArgReorder: true,
54+
UseShortOptionHandling: true,
5355
Flags: []cli.Flag{
5456
cli.BoolFlag{
5557
Name: "all, a",

vendor.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ github.com/opencontainers/selinux b29023b86e4a69d1b46b7e7b4e2b6fda03f0b9cd
1414
github.com/pborman/uuid ca53cad383cad2479bbba7f7a1a05797ec1386e4
1515
github.com/sirupsen/logrus v1.0.0
1616
github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7
17-
github.com/urfave/cli 7fb9c86b14e6a702a4157ccb5a863f07d844a207
17+
github.com/urfave/cli 8e01ec4cd3e2d84ab2fe90d8210528ffbb06d8ff
1818
golang.org/x/crypto 81e90905daefcd6fd217b62423c0908922eadb30
1919
golang.org/x/net 1c05540f6879653db88113bc4a2b70aec4bd491f
2020
golang.org/x/sys 7ddbeae9ae08c6a06a59597f0c9edbc5ff2444ce

0 commit comments

Comments
 (0)