# shellcheck shell=dash
___x_cmd_shodan_cve_info(){
    local id="$1"

    case "$1" in
        -h|--help)          ___x_cmd help -m shodan cve info; return  ;;
    esac

    id="CVE-${id#*-}"
    ___x_cmd_shodan_cve_info___app "$@"
}

___x_cmd_shodan_cve_info___app(){
    if ___x_cmd_is_stdout2tty; then
        # TODO: using less viewer ...
        ___x_cmd_shodan_cve_info___yml "$@"
    else
        ___x_cmd_shodan_cve_info___yml "$@"
    fi
}

___x_cmd_shodan_cve_info___yml(){
    ___x_cmd_shodan_cve_info___json "$@" | ___x_cmd j2y
}

___x_cmd_shodan_cve_info___json(){
    ___x_cmd_shodan_cve_info___raw "$@"
}

___x_cmd_shodan_cve_info___raw(){
    # curl 'https://cvedb.shodan.io/cve/cve-2024-3094' | x j2y
    ___x_cmd ccmd 1d -- ___x_cmd curl "https://cvedb.shodan.io/cve/$id"
}

