From 063b25cef542287ff0c1711929a4b53402030bc7 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 30 Oct 2017 12:12:40 -0400 Subject: [PATCH] Report error when arguments given to crio command Signed-off-by: Daniel J Walsh --- cmd/crio/main.go | 10 ++++++++++ test/command.bats | 12 ++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/command.bats diff --git a/cmd/crio/main.go b/cmd/crio/main.go index f7856c7f..e58adb11 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -409,6 +409,16 @@ func main() { }() } + args := c.Args() + if len(args) > 0 { + for _, command := range app.Commands { + if args[0] == command.Name { + break + } + } + return fmt.Errorf("command %q not supported", args[0]) + } + config := c.App.Metadata["config"].(*server.Config) if !config.SELinux { diff --git a/test/command.bats b/test/command.bats new file mode 100644 index 00000000..86e58f9d --- /dev/null +++ b/test/command.bats @@ -0,0 +1,12 @@ +#!/usr/bin/env bats + +load helpers + +@test "crio commands" { + run ${CRIO_BINARY} --config /dev/null config > /dev/null + echo "$output" + [ "$status" -eq 0 ] + run ${CRIO_BINARY} badoption > /dev/null + echo "$output" + [ "$status" -ne 0 ] +}