#!/bin/bash

appCrowdSecConsoleEnroll() {
    local args="$1"
    local token="$(authToolArg "$args" token)"
    if [[ -z "$token" ]]; then
        isNotice "No enrollment token provided — pass token=<value> via the Tools modal."
        isNotice "Get a token at https://app.crowdsec.net (free account). Enrolling shares attacker IPs + scenario names with CrowdSec SAS."
        return 1
    fi
    runSystem cscli console enroll "$token"
    checkSuccess "Enrolled with CrowdSec Console — community blocklists will start syncing"
    runSystem systemctl reload crowdsec
}
