diff --git a/cmd/crowdsec-cli/main.go b/cmd/crowdsec-cli/main.go index ba1b56489..e5dbe934d 100644 --- a/cmd/crowdsec-cli/main.go +++ b/cmd/crowdsec-cli/main.go @@ -153,7 +153,7 @@ It is meant to allow you to manage bans, parsers/scenarios/etc, api and generall log.Fatalf("failed to make branch hidden : %s", err) } - if os.Args[1] != "completion" { + if len(os.Args) > 1 && os.Args[1] != "completion" { cobra.OnInitialize(initConfig) } diff --git a/tests/bats/01_base.bats b/tests/bats/01_base.bats index 013721b01..57a6856e6 100644 --- a/tests/bats/01_base.bats +++ b/tests/bats/01_base.bats @@ -26,6 +26,13 @@ declare stderr #---------- +@test "$FILE cscli - usage" { + run -0 cscli + assert_output --partial "Usage:" + assert_output --partial "cscli [command]" + assert_output --partial "Available Commands:" +} + @test "$FILE cscli version" { run -0 cscli version assert_output --partial "version:"