blob: 2fb5b2413539c29ea757cce8842411cfc34cf2d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#compdef http
# Copyright (c) 2015 Github zsh-users
# Based on the initial work of http://github.com/zsh-users
METHODS=({% for method in methods -%} "{{ method }}" {% endfor -%})
_httpie_params () {
local ret=1 expl
local current=$words[$CURRENT]
if (( CURRENT > NORMARG )); then
local predecessor=$words[(( $CURRENT - 1 ))]
fi
if ! [[ $current == -* ]]; then
{% for flow_item in generate_flow() -%}
{{ compile_zsh(flow_item) }}
{% endfor -%}
fi
return $ret
}
_httpie_request_item() {
compset -P '(#b)([^:@=]#)'
local name=$match[1]
if false; then
false;
{% for option_name, _, operator, desc in request_items.nested_options -%}
elif compset -P '{{ operator }}'; then
{% if is_file_based_operator(operator) -%}
_files
{% else -%}
_message "$name {{ option_name }}"
{% endif %}
{% endfor -%}
else
typeset -a ops
ops=(
{% for option_name, _, operator, desc in request_items.nested_options -%}
"{{ escape_zsh(operator) }}:{{ desc }}"
{% endfor -%}
)
_describe -t httpparams 'parameter types' ops -Q -S ''
fi
return 1;
}
_httpie_method() {
_wanted http_method expl 'Request Method' \
compadd {% for method in methods -%} {{ method }} {% endfor -%} && ret=0
return 1;
}
_httpie_url() {
local ret=1
if ! [[ -prefix [-+.a-z0-9]#:// ]]; then
local expl
compset -S '[^:/]*' && compstate[to_end]=''
_wanted url-schemas expl 'URL schema' compadd -S '' http:// https:// && ret=0
else
_urls && ret=0
fi
return $ret
}
integer NORMARG
_arguments -n -C -s \
{% for argument in arguments -%}
{{ serialize_argument_to_zsh(argument) }} \
{% endfor -%}
'*:args:_httpie_params' && return 0
|