diff --git a/kill.go b/kill.go index e4f5831b..f80c4db7 100644 --- a/kill.go +++ b/kill.go @@ -72,6 +72,9 @@ signal to the init process of the "ubuntu01" container: if err := checkArgs(context, 1, minArgs); err != nil { return err } + if err := checkArgs(context, 2, maxArgs); err != nil { + return err + } container, err := getContainer(context) if err != nil { return err diff --git a/utils.go b/utils.go index ce610440..3c3785b9 100644 --- a/utils.go +++ b/utils.go @@ -13,6 +13,7 @@ import ( const ( exactArgs = iota minArgs + maxArgs ) func checkArgs(context *cli.Context, expected, checkType int) error { @@ -27,6 +28,10 @@ func checkArgs(context *cli.Context, expected, checkType int) error { if context.NArg() < expected { err = fmt.Errorf("%s: %q requires a minimum of %d argument(s)", os.Args[0], cmdName, expected) } + case maxArgs: + if context.NArg() > expected { + err = fmt.Errorf("%s: %q requires a maximum of %d argument(s)", os.Args[0], cmdName, expected) + } } if err != nil {