Browse Source

add output raw for ban list (#108)

Co-authored-by: AlteredCoder <AlteredCoder>
AlteredCoder 5 years ago
parent
commit
81ef26f406
1 changed files with 6 additions and 1 deletions
  1. 6 1
      cmd/crowdsec-cli/ban.go

+ 6 - 1
cmd/crowdsec-cli/ban.go

@@ -96,7 +96,12 @@ func BanList() error {
 	if err != nil {
 		return fmt.Errorf("unable to get records from sqlite : %v", err)
 	}
-	if config.output == "json" {
+	if config.output == "raw" {
+		fmt.Printf("source,ip,reason,bans,action,country,as,events_count,expiration\n")
+		for _, rm := range ret {
+			fmt.Printf("%s,%s,%s,%s,%s,%s,%s,%s,%s\n", rm["source"], rm["iptext"], rm["reason"], rm["bancount"], rm["action"], rm["cn"], rm["as"], rm["events_count"], rm["until"])
+		}
+	} else if config.output == "json" {
 		x, _ := json.MarshalIndent(ret, "", " ")
 		fmt.Printf("%s", string(x))
 	} else if config.output == "human" {