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 <long.wanglong@huawei.com>
This commit is contained in:
Wang Long 2016-10-20 10:01:47 +08:00
parent 850b9c0b50
commit ba1c0b4fa3
1 changed files with 6 additions and 0 deletions

View File

@ -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