From ba1c0b4fa3b4886b4e34e856519827e5f71a536f Mon Sep 17 00:00:00 2001 From: Wang Long Date: Thu, 20 Oct 2016 10:01:47 +0800 Subject: [PATCH] check the arguments for `runc create` This patch checks the arguments for command `runc create`. the `create` command requires exactly one argument eg: root@ubuntu:~# runc create -b /mycontainer/ a root@ubuntu:~# runc list ID PID STATUS BUNDLE CREATED a 61637 created /mycontainer 2016-10-20T08:21:20.169810942Z root@ubuntu:~# runc create -b /mycontainer/ a b runc: "create" requires exactly one argument root@ubuntu:~# runc create -b /mycontainer/ runc: "create" requires exactly one argument Signed-off-by: Wang Long --- create.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/create.go b/create.go index 899e54ca..77663133 100644 --- a/create.go +++ b/create.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "github.com/urfave/cli" @@ -48,6 +49,11 @@ command(s) that get executed on start, edit the args parameter of the spec. See }, }, Action: func(context *cli.Context) error { + if context.NArg() != 1 { + fmt.Printf("Incorrect Usage.\n\n") + cli.ShowCommandHelp(context, "create") + return fmt.Errorf("runc: \"create\" requires exactly one argument") + } spec, err := setupSpec(context) if err != nil { return err