# shellcheck shell=bash disable=SC2154,SC2034
# Restricted to the enterprise user
___x_cmd_shodan_scan_add(){
    local X_help_cmd='x help -m shodan scan add';  help:arg:parse
    shodan:arg:format:raw:json2app:init
    local port=; local protocol=
    while [ "$#" -gt 0 ]; do
        shodan:arg:format:raw:json2app:match

        case "$1" in
            --protocol)     protocol="$2";  shift 2 ;;
            --port)         port="$2";      shift 2 ;;
            *)              N=shodan M="x shodan scan add --port <port> --protocol <protocol>" log:ret:1 ;;
        esac
    done
    shodan:arg:format:raw:json2app:fini

    [ -n "$protocol" ]  ||  N=shodan M="Provide a protocol"     log:ret:1
    [ -n "$port" ]      ||  N=shodan M="Provide a port"         log:ret:1

    set --  -d "port=${port}" -d "protocol=${protocol}"
    ___x_cmd_shodan_scan_add___"$format" "$@"
}



___x_cmd_shodan_scan_add___app(){
    local data;     data="$( ___x_cmd_shodan_scan_add___raw "$@" )"     || shodan:data:ret
    ___x_cmd_pipevar data       x j2y
}

___x_cmd_shodan_scan_add___json(){
    local data;     data="$( ___x_cmd_shodan_scan_add___raw "$@" )"     || shodan:data:ret
    ___x_cmd_pipevar data
}

___x_cmd_shodan_scan_add___raw(){
    ___x_cmd_shodan_ourl post "/shodan/scan/internet" "$@"
}
