From 5cc722bedd4f400bdf40f90038f0ccc6361617ff Mon Sep 17 00:00:00 2001 From: Sascha Grunert Date: Thu, 29 Aug 2019 09:59:09 +0200 Subject: [PATCH] Treat first `crictl stats` argument as filter ID The first argument supplied to `crictl stats` can be taken as the filter ID of the container, whereas `--id` gets precedence. Signed-off-by: Sascha Grunert --- cmd/crictl/stats.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/crictl/stats.go b/cmd/crictl/stats.go index 5b6c41ed02..3d4feaf3cd 100644 --- a/cmd/crictl/stats.go +++ b/cmd/crictl/stats.go @@ -50,6 +50,7 @@ var statsCommand = cli.Command{ Usage: "List container(s) resource usage statistics", SkipArgReorder: true, UseShortOptionHandling: true, + ArgsUsage: "[ID]", Flags: []cli.Flag{ cli.BoolFlag{ Name: "all, a", @@ -90,9 +91,14 @@ var statsCommand = cli.Command{ } defer closeConnection(context, runtimeConn) + id := context.String("id") + if id == "" && context.Args() != nil { + id = context.Args()[0] + } + opts := statsOptions{ all: context.Bool("all"), - id: context.String("id"), + id: id, podID: context.String("pod"), sample: time.Duration(context.Int("seconds")) * time.Second, output: context.String("output"),