-
-
Notifications
You must be signed in to change notification settings - Fork 466
/
zephir-autocomplete
68 lines (61 loc) · 1.7 KB
/
zephir-autocomplete
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
# Zephir Bash completion
#
# This file is part of the Zephir.
#
# (c) Phalcon Team <[email protected]>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
#
# Usage:
#
# 1. Copy this file to the common place:
#
# ln -s zephir-autocomplete /etc/bash_completion.d/zephir-autocomplete
#
# 2. Load zephir-autocomplete from within your ~/.bash_profile:
#
# if [ -f /etc/bash_completion.d/zephir-autocomplete ]; then
# source /etc/bash_completion.d/zephir-autocomplete
# fi
#
# 3. Restart your shell, or reload your ~/.bash_profile:
#
# source ~/.bash_profile
#
function _zephir_completion() {
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local commands="api build clean compile fullclean generate help"
commands+=" init install list stubs"
if [[ $COMP_CWORD -gt 1 ]]
then
local first="${COMP_WORDS[1]}"
if [[ "$cur" == -* ]]
then
declare -a a_commands=( "$( echo "$commands" | tr " " "\\n" )" )
for i in "${a_commands[@]}"
do
if [ "$i" = "$first" ]
then
local opts
opts=$( zephir "$first" -h --no-ansi | \
tr -cs '[=-=][:alpha:]_' '[\n*]' | \
grep '^-' )
COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
fi
done
else
COMPREPLY+=( $( compgen -W "namespace" -- "${cur}" ) )
fi
elif [[ "$cur" == -* ]]
then
local opts
opts="--help --quiet --verbose --version --ansi --no-ansi"
opts+=" --dumpversion -dumpversion --vernum"
COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) )
else
COMPREPLY=( $( compgen -W "${commands}" -- "${cur}" ) )
fi
}
complete -F _zephir_completion zephir