ab140683689a38006854533a40e0fe54427d9181
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/httpie/README.md b/plugins/httpie/README.md
2index 56aa6a8cae6c122fb9a3b244f8feb331c608a0fe..f22d3a64e514fa74bbddaadabe9a1e327467f490 100644
3--- a/plugins/httpie/README.md
4+++ b/plugins/httpie/README.md
5@@ -1,6 +1,15 @@
6-## HTTPie
7-**Maintainer:** [lululau](https://github.com/lululau)
8+# HTTPie plugin
9+
10+This plugin adds completion for [HTTPie](https://httpie.org), a command line HTTP
11+client, a friendlier cURL replacement.
12+
13+To use it, add `httpie` to the plugins array in your zshrc file:
14
15-This plugin adds completion for HTTPie, which is a command line HTTP client, a user-friendly cURL replacement.
16+```zsh
17+plugins=(... httpie)
18+```
19
20-[HTTPie Homepage](https://httpie.org)
21+It uses completion from [zsh-completions](https://github.com/zsh-users/zsh-completions).
22+
23+
24+**Maintainer:** [lululau](https://github.com/lululau)
25diff --git a/plugins/httpie/_httpie b/plugins/httpie/_httpie
26new file mode 100644
27index 0000000000000000000000000000000000000000..4d702ef604459cddf11fdfcef2db5496a711d46e
28--- /dev/null
29+++ b/plugins/httpie/_httpie
30@@ -0,0 +1,181 @@
31+#compdef http
32+# ------------------------------------------------------------------------------
33+# Copyright (c) 2015 Github zsh-users - http://github.com/zsh-users
34+# All rights reserved.
35+#
36+# Redistribution and use in source and binary forms, with or without
37+# modification, are permitted provided that the following conditions are met:
38+# * Redistributions of source code must retain the above copyright
39+# notice, this list of conditions and the following disclaimer.
40+# * Redistributions in binary form must reproduce the above copyright
41+# notice, this list of conditions and the following disclaimer in the
42+# documentation and/or other materials provided with the distribution.
43+# * Neither the name of the zsh-users nor the
44+# names of its contributors may be used to endorse or promote products
45+# derived from this software without specific prior written permission.
46+#
47+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
48+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
49+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50+# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
51+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
53+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
54+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
55+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
56+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57+# ------------------------------------------------------------------------------
58+# Description
59+# -----------
60+#
61+# Completion script for httpie 0.7.2 (http://httpie.org)
62+#
63+# ------------------------------------------------------------------------------
64+# Authors
65+# -------
66+#
67+# * Akira Maeda <https://github.com/glidenote>
68+# * Valodim <https://github.com/Valodim>
69+# * Claus Klingberg <https://github.com/cjk>
70+#
71+# ------------------------------------------------------------------------------
72+# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
73+# vim: ft=zsh sw=2 ts=2 et
74+# ------------------------------------------------------------------------------
75+
76+_httpie_params () {
77+
78+ local ret=1 expl
79+
80+ # or a url
81+ if (( CURRENT <= NORMARG+1 )) && [[ $words[NORMARG] != *:* ]] ; then
82+ _httpie_urls && ret=0
83+
84+ # regular param, if we already have a url
85+ elif (( CURRENT > NORMARG )); then
86+
87+ # if the suffix is precisely : this is shorthand for a header
88+ if [[ -prefix ':' ]]; then
89+ PREFIX=
90+ SUFFIX=:
91+ fi
92+
93+ # if we are in front of a : (possibly due to the PREFIX move before)
94+ if [[ -suffix ':' ]]; then
95+
96+ # this is rather buggy with normal tab behavior :\
97+ compstate[insert]=menu
98+ _wanted http_header expl 'HTTP Header' \
99+ compadd -s ':' -S '' -- Content-Type Cookie && return 0
100+ fi
101+
102+ # ignore all prefix stuff
103+ compset -P '(#b)([^:@=]#)'
104+ local name=$match[1]
105+
106+ if compset -P '='; then
107+ _message "$name data field value"
108+ elif compset -P '@'; then
109+ _files
110+ elif compset -P ':=@'; then
111+ _files
112+ elif compset -P ':='; then
113+ _message "$name raw json data"
114+ elif compset -P '=='; then
115+ _message "$name url parameter value"
116+ elif compset -P ':'; then
117+ _message "$name header content"
118+ else
119+ typeset -a ops
120+ ops=(
121+ '=:data field'
122+ '\::header'
123+ '==:request parameter'
124+ '@:data file field'
125+ '\:=:raw json field'
126+ '\:=@:raw json field file path'
127+ )
128+ _describe -t httpparams "parameter types" ops -Q -S ''
129+ fi
130diff --git a/plugins/httpie/httpie.plugin.zsh b/plugins/httpie/httpie.plugin.zsh
131deleted file mode 100644
132index 68ead6c67f16d94ffee2dc4985eb811418053083..0000000000000000000000000000000000000000
133--- a/plugins/httpie/httpie.plugin.zsh
134+++ /dev/null
135@@ -1,33 +0,0 @@
136-function _httpie_completion() {
137- _arguments -C \
138- '(- 1 *)--version[display version information]' \
139- '(-j|--json)'{-j,--json}'[(default) Data items from the command line are serialized as a JSON object]' \
140- '(-f|--form)'{-f,--form}'[Data items from the command line are serialized as form fields]' \
141- '(--pretty)--pretty[<all,colors,format,none> Controls output processing]:options' \
142- '(-s|--style)'{-s,--style}'[Output coloring style]' \
143- '(-p|--print)'{-p,--print}'[String specifying what the output should contain: H(request headers), B(request body), h(response headers), b(response body)]' \
144- '(-v|--verbose)'{-v,--verbose}'[Print the whole request as well as the response. Shortcut for --print=HBbh.]' \
145- '(-h|--headers)'{-h,--headers}'[Print only the response headers. Shortcut for --print=h]' \
146- '(-b|--body)'{-b,--body}'[Print only the response body. Shortcut for --print=b]' \
147- '(-S|--stream)'{-S,--stream}'[Always stream the output by line, i.e., behave like `tail -f'"'"']' \
148- '(-o|--output)'{-o,--output}'[Save output to FILE]:file:_files' \
149- '(-d|--download)'{-d,--download}'[Do not print the response body to stdout. Rather, download it and store it in a file. The filename is guessed unless specified with --output filename. This action is similar to the default behaviour of wget.]' \
150- '(-c|--continue)'{-c,--continue}'[Resume an interrupted download. Note that the --output option needs to be specified as well.]' \
151- '(--session)--session[Create, or reuse and update a session. Within a session, custom headers, auth credential, as well as any cookies sent by the server persist between requests]:file:_files' \
152- '(--session-read-only)--session-read-only[Create or read a session without updating it form the request/response exchange]:file:_files' \
153- '(-a|--auth)'{-a,--auth}'[<USER:PASS> If only the username is provided (-a username), HTTPie will prompt for the password]' \
154- '(--auth-type)--auth-type[<basic, digest> The authentication mechanism to be used. Defaults to "basic".]' \
155- '(--proxy)--proxy[<PROTOCOL:PROXY_URL> String mapping protocol to the URL of the proxy]' \
156- '(--follow)--follow[Set this flag if full redirects are allowed (e.g. re-POST-ing of data at new Location).]' \
157- '(--verify)--verify[<VERIFY> Set to "no" to skip checking the host'"'"'s SSL certificate. You can also pass the path to a CA_BUNDLE file for private certs. You can also set the REQUESTS_CA_BUNDLE environment variable. Defaults to "yes".]' \
158- '(--timeout)--timeout[<SECONDS> The connection timeout of the request in seconds. The default value is 30 seconds]' \
159- '(--check-status)--check-status[By default, HTTPie exits with 0 when no network or other fatal errors occur. This flag instructs HTTPie to also check the HTTP status code and exit with an error if the status indicates one.]' \
160- '(--ignore-stdin)--ignore-stdin[Do not attempt to read stdin]' \
161- '(--help)--help[Show this help message and exit]' \
162- '(--traceback)--traceback[Prints exception traceback should one occur]' \
163- '(--debug)--debug[Prints exception traceback should one occur, and also other information that is useful for debugging HTTPie itself and for reporting bugs]' \
164- '1: :->cmds' \
165- '*: :->args' && ret=0
166-}
167-
168-compdef _httpie_completion http