# shellcheck shell=dash disable=SC2154,SC2034
___x_cmd_shodan_scan_protocol(){
    local X_help_cmd='x help -m shodan scan protocol';  help:arg:parse
    shodan:arg:format:all

    shodan:info "List all protocols that can be used when performing on-demand Internet scans via Shodan"
    ___x_cmd_shodan_scan_protocol___"${format}"
}

___x_cmd_shodan_scan_protocol___app(){
    local data;     data="$( ___x_cmd_shodan_scan_protocol___csv )"     || shodan:data:ret
    ___x_cmd_pipevar data       x csv app --return print
}

___x_cmd_shodan_scan_protocol___csv(){
    local data;     data="$( ___x_cmd_shodan_scan_protocol___json )"    || shodan:data:ret
    ___x_cmd_pipevar data       ___x_cmd_shodan_scan_protocol___parse_json2csv
}

___x_cmd_shodan_scan_protocol___json(){
    local data;     data="$( ___x_cmd_shodan_scan_protocol___raw )"     || shodan:data:ret
    printf "%s\n" "$data"
}

___x_cmd_shodan_scan_protocol___raw(){
    X_CCMD_TIMEOUT=10m ___x_cmd_shodan_ourl get "/shodan/protocols"
}

# Section: parse
___x_cmd_shodan_scan_protocol___parse_json2csv(){
    x ja '{if(v() !~"{|}")print "\""k()"\""",""\""v()"\""}' |\
        x csv header --add  Protocol Description
}
# EndSection
