kill: requires max 2 arguments
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
1c9c074d79
commit
1d6447797e
3
kill.go
3
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
|
||||
|
|
5
utils.go
5
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 {
|
||||
|
|
Loading…
Reference in New Issue