Check args numbers before application start

Add a general args number validator for all client commands.

Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
This commit is contained in:
Zhang Wei
2016-10-28 23:43:10 +08:00
parent f156f73c2a
commit b517076907
16 changed files with 74 additions and 20 deletions
+2 -5
View File
@@ -1,7 +1,6 @@
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
@@ -49,10 +48,8 @@ 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")
if err := checkArgs(context, 1, exactArgs); err != nil {
return err
}
if err := revisePidFile(context); err != nil {
return err