#compdef rwalk

autoload -U is-at-least

_rwalk() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" \
'-m+[Crawl mode]:MODE:(recursive recursion r classic c spider s)' \
'--mode=[Crawl mode]:MODE:(recursive recursion r classic c spider s)' \
'-t+[Number of threads to use]:THREADS: ' \
'--threads=[Number of threads to use]:THREADS: ' \
'-d+[Crawl recursively until given depth]:DEPTH: ' \
'--depth=[Crawl recursively until given depth]:DEPTH: ' \
'-o+[Output file]:FILE: ' \
'--output=[Output file]:FILE: ' \
'--timeout=[Request timeout in seconds]:TIMEOUT: ' \
'--to=[Request timeout in seconds]:TIMEOUT: ' \
'-u+[User agent]:USER_AGENT: ' \
'--user-agent=[User agent]:USER_AGENT: ' \
'-X+[HTTP method]:METHOD: ' \
'--method=[HTTP method]:METHOD: ' \
'-D+[Data to send with the request]:DATA: ' \
'--data=[Data to send with the request]:DATA: ' \
'*-H+[Headers to send]:key:value: ' \
'*--headers=[Headers to send]:key:value: ' \
'*-C+[Cookies to send]:key=value: ' \
'*--cookies=[Cookies to send]:key=value: ' \
'-R+[Follow redirects]:COUNT: ' \
'--follow-redirects=[Follow redirects]:COUNT: ' \
'-c+[Configuration file]:CONFIG: ' \
'--config=[Configuration file]:CONFIG: ' \
'--throttle=[Request throttling (requests per second) per thread]:THROTTLE: ' \
'-M+[Max time to run (will abort after given time) in seconds]:MAX_TIME: ' \
'--max-time=[Max time to run (will abort after given time) in seconds]:MAX_TIME: ' \
'*--show=[Show response additional body information]:SHOW: ' \
'--save-file=[Custom save file]:FILE: ' \
'*-T+[Wordlist transformations\: "lower", "upper", "prefix", "suffix", "capitalize", "reverse", "remove", "replace"]:TRANSFORM: ' \
'*--transform=[Wordlist transformations\: "lower", "upper", "prefix", "suffix", "capitalize", "reverse", "remove", "replace"]:TRANSFORM: ' \
'*-w+[Wordlist filtering\: "contains", "starts", "ends", "regex", "length"]:KEY:FILTER: ' \
'*--wordlist-filter=[Wordlist filtering\: "contains", "starts", "ends", "regex", "length"]:KEY:FILTER: ' \
'*--wf=[Wordlist filtering\: "contains", "starts", "ends", "regex", "length"]:KEY:FILTER: ' \
'*-f+[Response filtering\: "time", "status", "contains", "starts", "end", "regex", "length", "hash", "header", "json", "depth", "type"]:KEY:FILTER: ' \
'*--filter=[Response filtering\: "time", "status", "contains", "starts", "end", "regex", "length", "hash", "header", "json", "depth", "type"]:KEY:FILTER: ' \
'--request-file=[Request file (.http, .rest)]:FILE: ' \
'--rf=[Request file (.http, .rest)]:FILE: ' \
'-P+[Proxy URL]:URL: ' \
'--proxy=[Proxy URL]:URL: ' \
'--proxy-auth=[Proxy username and password]:USER:PASS: ' \
'--force[Force scan even if the target is not responding]' \
'--hit-connection-errors[Consider connection errors as a hit]' \
'--hce[Consider connection errors as a hit]' \
'--no-color[Don'\''t use colors You can also set the NO_COLOR environment variable]' \
'-q[Quiet mode]' \
'--quiet[Quiet mode]' \
'-i[Interactive mode]' \
'--interactive[Interactive mode]' \
'--insecure[Insecure mode, disables SSL certificate validation]' \
'--unsecure[Insecure mode, disables SSL certificate validation]' \
'-r[Resume from a saved file]' \
'--resume[Resume from a saved file]' \
'--no-save[Don'\''t save the state in case you abort]' \
'--keep-save[Keep the save file after finishing when using --resume]' \
'--keep[Keep the save file after finishing when using --resume]' \
'--or[Treat filters as or instead of and]' \
'--force-recursion[Force the recursion over non-directories]' \
'--fr[Force the recursion over non-directories]' \
'--subdomains[Allow subdomains to be scanned in spider mode]' \
'--sub[Allow subdomains to be scanned in spider mode]' \
'--generate-markdown[Generate markdown help - for developers]' \
'--generate-completions[Generate shell completions - for developers]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::url -- Target URL:' \
'*::wordlists -- Wordlist(s):' \
&& ret=0
}

(( $+functions[_rwalk_commands] )) ||
_rwalk_commands() {
    local commands; commands=()
    _describe -t commands 'rwalk commands' commands "$@"
}

if [ "$funcstack[1]" = "_rwalk" ]; then
    _rwalk "$@"
else
    compdef _rwalk rwalk
fi
