mirror of
https://github.com/ducaale/xh.git
synced 2025-05-05 15:32:50 +00:00
* Allow for completion and man page generation at runtime and support for Elvish and Nshull * Refine runtime generation based on feedback provided
161 lines
7.0 KiB
Plaintext
161 lines
7.0 KiB
Plaintext
#compdef xh
|
|
|
|
autoload -U is-at-least
|
|
|
|
_xh() {
|
|
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[@]}" : \
|
|
'--raw=[Pass raw request data without extra processing]:RAW:_default' \
|
|
'--pretty=[Controls output processing]:STYLE:((all\:"(default) Enable both coloring and formatting"
|
|
colors\:"Apply syntax highlighting to output"
|
|
format\:"Pretty-print json and sort headers"
|
|
none\:"Disable both coloring and formatting"))' \
|
|
'*--format-options=[Set output formatting options]:FORMAT_OPTIONS:_default' \
|
|
'-s+[Output coloring style]:THEME:(auto solarized monokai fruity)' \
|
|
'--style=[Output coloring style]:THEME:(auto solarized monokai fruity)' \
|
|
'--response-charset=[Override the response encoding for terminal display purposes]:ENCODING:_default' \
|
|
'--response-mime=[Override the response mime type for coloring and formatting for the terminal]:MIME_TYPE:_default' \
|
|
'-p+[String specifying what the output should contain]:FORMAT:_default' \
|
|
'--print=[String specifying what the output should contain]:FORMAT:_default' \
|
|
'-P+[The same as --print but applies only to intermediary requests/responses]:FORMAT:_default' \
|
|
'--history-print=[The same as --print but applies only to intermediary requests/responses]:FORMAT:_default' \
|
|
'-o+[Save output to FILE instead of stdout]:FILE:_files' \
|
|
'--output=[Save output to FILE instead of stdout]:FILE:_files' \
|
|
'--session=[Create, or reuse and update a session]:FILE:_default' \
|
|
'(--session)--session-read-only=[Create or read a session without updating it form the request/response exchange]:FILE:_default' \
|
|
'-A+[Specify the auth mechanism]:AUTH_TYPE:(basic bearer digest)' \
|
|
'--auth-type=[Specify the auth mechanism]:AUTH_TYPE:(basic bearer digest)' \
|
|
'-a+[Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer)]:USER[:PASS] | TOKEN:_default' \
|
|
'--auth=[Authenticate as USER with PASS (-A basic|digest) or with TOKEN (-A bearer)]:USER[:PASS] | TOKEN:_default' \
|
|
'--bearer=[Authenticate with a bearer token]:TOKEN:_default' \
|
|
'--max-redirects=[Number of redirects to follow. Only respected if --follow is used]:NUM:_default' \
|
|
'--timeout=[Connection timeout of the request]:SEC:_default' \
|
|
'*--proxy=[Use a proxy for a protocol. For example\: --proxy https\:http\://proxy.host\:8080]:PROTOCOL:URL:_default' \
|
|
'--verify=[If "no", skip SSL verification. If a file path, use it as a CA bundle]:VERIFY:_default' \
|
|
'--cert=[Use a client side certificate for SSL]:FILE:_files' \
|
|
'--cert-key=[A private key file to use with --cert]:FILE:_files' \
|
|
'--ssl=[Force a particular TLS version]:VERSION:(auto tls1 tls1.1 tls1.2 tls1.3)' \
|
|
'--default-scheme=[The default scheme to use if not specified in the URL]:SCHEME:_default' \
|
|
'--http-version=[HTTP version to use]:VERSION:(1.0 1.1 2 2-prior-knowledge)' \
|
|
'*--resolve=[Override DNS resolution for specific domain to a custom IP]:HOST:ADDRESS:_default' \
|
|
'--interface=[Bind to a network interface or local IP address]:NAME:_default' \
|
|
'--generate=[Generate shell completions or man pages]:KIND:(complete-bash complete-elvish complete-fish complete-nushell complete-powershell complete-zsh man)' \
|
|
'-j[(default) Serialize data items from the command line as a JSON object]' \
|
|
'--json[(default) Serialize data items from the command line as a JSON object]' \
|
|
'-f[Serialize data items from the command line as form fields]' \
|
|
'--form[Serialize data items from the command line as form fields]' \
|
|
'(--raw)--multipart[Like --form, but force a multipart/form-data request even without files]' \
|
|
'-h[Print only the response headers. Shortcut for --print=h]' \
|
|
'--headers[Print only the response headers. Shortcut for --print=h]' \
|
|
'-b[Print only the response body. Shortcut for --print=b]' \
|
|
'--body[Print only the response body. Shortcut for --print=b]' \
|
|
'-m[Print only the response metadata. Shortcut for --print=m]' \
|
|
'--meta[Print only the response metadata. Shortcut for --print=m]' \
|
|
'*-v[Print the whole request as well as the response]' \
|
|
'*--verbose[Print the whole request as well as the response]' \
|
|
'--debug[Print full error stack traces and debug log messages]' \
|
|
'--all[Show any intermediary requests/responses while following redirects with --follow]' \
|
|
'*-q[Do not print to stdout or stderr]' \
|
|
'*--quiet[Do not print to stdout or stderr]' \
|
|
'-S[Always stream the response body]' \
|
|
'--stream[Always stream the response body]' \
|
|
'-d[Download the body to a file instead of printing it]' \
|
|
'--download[Download the body to a file instead of printing it]' \
|
|
'-c[Resume an interrupted download. Requires --download and --output]' \
|
|
'--continue[Resume an interrupted download. Requires --download and --output]' \
|
|
'--ignore-netrc[Do not use credentials from .netrc]' \
|
|
'--offline[Construct HTTP requests without sending them anywhere]' \
|
|
'--check-status[(default) Exit with an error status code if the server replies with an error]' \
|
|
'-F[Do follow redirects]' \
|
|
'--follow[Do follow redirects]' \
|
|
'--native-tls[Use the system TLS library instead of rustls (if enabled at compile time)]' \
|
|
'--https[Make HTTPS requests if not specified in the URL]' \
|
|
'-4[Resolve hostname to ipv4 addresses only]' \
|
|
'--ipv4[Resolve hostname to ipv4 addresses only]' \
|
|
'-6[Resolve hostname to ipv6 addresses only]' \
|
|
'--ipv6[Resolve hostname to ipv6 addresses only]' \
|
|
'-I[Do not attempt to read stdin]' \
|
|
'--ignore-stdin[Do not attempt to read stdin]' \
|
|
'--curl[Print a translation to a curl command]' \
|
|
'--curl-long[Use the long versions of curl'\''s flags]' \
|
|
'--help[Print help]' \
|
|
'--no-json[]' \
|
|
'--no-form[]' \
|
|
'--no-multipart[]' \
|
|
'--no-raw[]' \
|
|
'--no-pretty[]' \
|
|
'--no-format-options[]' \
|
|
'--no-style[]' \
|
|
'--no-response-charset[]' \
|
|
'--no-response-mime[]' \
|
|
'--no-print[]' \
|
|
'--no-headers[]' \
|
|
'--no-body[]' \
|
|
'--no-meta[]' \
|
|
'--no-verbose[]' \
|
|
'--no-debug[]' \
|
|
'--no-all[]' \
|
|
'--no-history-print[]' \
|
|
'--no-quiet[]' \
|
|
'--no-stream[]' \
|
|
'--no-output[]' \
|
|
'--no-download[]' \
|
|
'--no-continue[]' \
|
|
'--no-session[]' \
|
|
'--no-session-read-only[]' \
|
|
'--no-auth-type[]' \
|
|
'--no-auth[]' \
|
|
'--no-bearer[]' \
|
|
'--no-ignore-netrc[]' \
|
|
'--no-offline[]' \
|
|
'--no-check-status[]' \
|
|
'--no-follow[]' \
|
|
'--no-max-redirects[]' \
|
|
'--no-timeout[]' \
|
|
'--no-proxy[]' \
|
|
'--no-verify[]' \
|
|
'--no-cert[]' \
|
|
'--no-cert-key[]' \
|
|
'--no-ssl[]' \
|
|
'--no-native-tls[]' \
|
|
'--no-default-scheme[]' \
|
|
'--no-https[]' \
|
|
'--no-http-version[]' \
|
|
'--no-resolve[]' \
|
|
'--no-interface[]' \
|
|
'--no-ipv4[]' \
|
|
'--no-ipv6[]' \
|
|
'--no-ignore-stdin[]' \
|
|
'--no-curl[]' \
|
|
'--no-curl-long[]' \
|
|
'--no-generate[]' \
|
|
'--no-help[]' \
|
|
'-V[Print version]' \
|
|
'--version[Print version]' \
|
|
'::raw_method_or_url -- The request URL, preceded by an optional HTTP method:_default' \
|
|
'*::raw_rest_args -- Optional key-value pairs to be included in the request.:_default' \
|
|
&& ret=0
|
|
}
|
|
|
|
(( $+functions[_xh_commands] )) ||
|
|
_xh_commands() {
|
|
local commands; commands=()
|
|
_describe -t commands 'xh commands' commands "$@"
|
|
}
|
|
|
|
if [ "$funcstack[1]" = "_xh" ]; then
|
|
_xh "$@"
|
|
else
|
|
compdef _xh xh
|
|
fi
|