From fbf272d4db1a28f4a56a9c8e8de9d0c6de33d218 Mon Sep 17 00:00:00 2001 From: Jefferson Julio Date: Sat, 14 May 2022 20:20:45 -0300 Subject: ZSH completion. --- completions/zsh/_rest-run | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 completions/zsh/_rest-run (limited to 'completions') diff --git a/completions/zsh/_rest-run b/completions/zsh/_rest-run new file mode 100644 index 0000000..dfa6873 --- /dev/null +++ b/completions/zsh/_rest-run @@ -0,0 +1,67 @@ +#compdef _rest-run rest-run + +# zsh completion for rest-run -*- shell-script -*- + +function __debug { + echo "$1" >> /tmp/_rest-run.log +} + +function _rest-run { + local line + local -a args + + args+=( + '1:*:(POST GET PUT PATCH DELETE)' + '--no-edit[Skip request body edit]' + '--body[Body options]: :_rest-run_body_opts' + '--response[Response options]: :_rest-run_response_opts' + '*-h[HTTP header]' + '--paginate[Paginate request response]' + ) + + _arguments -C $args +} + +function _rest-run_body_opts { + local -a _descriptions _values + + _descriptions=( + 'default -- create a request body using the default editor' + 'last -- use the last request' + 'history -- pick from the request history' + 'stdin -- reads from piped input' + ) + + _values=( + 'default' + 'last' + 'history' + 'stdin' + ) + + compadd -d _descriptions -a _values +} + +function _rest-run_response_opts { + local -a _descriptions _values + + _descriptions=( + 'default -- store the request on cache' + 'last -- read last request, skip request' + 'history -- pick from the response history, skip request' + ) + + _values=( + 'default' + 'last' + 'history' + ) + + compadd -d _descriptions -a _values +} + +if [ "$funcstack[1]" = "_rest-run" ]; then + _rest-run +fi + +compdef _rest-run rest-run -- cgit v1.2.3