# shellcheck shell=dash disable=SC2154,SC2034
# https://geonet.shodan.io/docs#/default/dns_query_api_dns__hostname__get
___x_cmd_shodan_dnsq(){
    local X_help_cmd='x help -m shodan geo dnsq';   help:arg-null:parse
    shodan:arg:format:raw:json2app:init

    local rtype=A; local hostname=
    while [ "$#" -gt 0 ]; do
        shodan:arg:format:raw:json2app:match
        case "$1" in
            --rtype)    rtype="$2";      shift 2    ;;
            *)          hostname="$1";   break      ;;
        esac
    done

    shodan:arg:format:raw:json2app:fini
    [ -n "$hostname" ] || N=shodan M="Provide a hostname" log:ret:64

    ___x_cmd_shodan_dnsq___"$format"
}

___x_cmd_shodan_dnsq___raw(){
    x curl -sS "https://geonet.shodan.io/api/dns/${hostname}?rtype=${rtype}"
}

___x_cmd_shodan_dnsq___json(){
    local data; data="$( ___x_cmd_shodan_dnsq___raw )"   || shodan:data:ret
    ___x_cmd_pipevar data
}

___x_cmd_shodan_dnsq___app(){
    local data; data="$( ___x_cmd_shodan_dnsq___raw )"   || shodan:data:ret
    ___x_cmd_pipevar data   x j2y
}
