# shellcheck shell=dash
___x_cmd_shodan_cpe_count(){
    local format=yml

    local product=

    while [ $# -gt 0 ]; do
        case "$1" in
            --product)          product="$2";        shift 2 ;;

            --json)             format=json;         shift 1 ;;
            --yml)              format=yml;          shift 1 ;;

            -h|--help)          ___x_cmd help -m shodan cpe count; return  ;;
            # --app)              format=csv;          shift 1 ;;
            *)                  break ;;
        esac
    done
    ___x_cmd_shodan_cpe_count___"$format"
}


___x_cmd_shodan_cpe_count___yml(){
    ___x_cmd_shodan_cpe_count___json | ___x_cmd j2y
}

___x_cmd_shodan_cpe_count___json(){
    ___x_cmd_shodan_cpe_count___raw
}

___x_cmd_shodan_cpe_count___raw(){
    [ -z "$product" ] || set -- "$@" --data-urlencode "product=$product"

    ___x_cmd ccmd 1h -- \
        ___x_cmd curl --silent --get \
            --data-urlencode count=true \
            https://cvedb.shodan.io/cpes  "$@"
}
