Skip to content

Commit

Permalink
fix "cscli" without arguments (#1406)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Mar 31, 2022
1 parent cea793f commit b202e38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/crowdsec-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
7 changes: 7 additions & 0 deletions tests/bats/01_base.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
Expand Down

0 comments on commit b202e38

Please sign in to comment.