blob: fc6df0594025df2ac031a63e529fb8433b441c71 (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# bash completion for dmd
_filedir_dmd()
{
cur=$(echo "${cur}" | sed 's:^'${1}'::')
if test "${2}" == "(*)" ;then
_filedir
else
_filedir '@'${2}
fi
cur="${1}${cur}"
J=0
F=0
for I in ${COMPREPLY[@]}
do
if test -d ${I} ;then
COMPREPLY[${J}]="${1}${I}/"
else
COMPREPLY[${J}]="${1}${I}"
F=1
fi
J=$((J + 1))
done
if test ${F} -eq 1 -a ${J} -eq 1 ;then
compopt +o nospace
fi
}
_dmd()
{
_dmd_opts="$(dmd --help 2>&1 | sed -n 's/^\s*\(-\+\w*=*-*\).*/\1/p' | \
sed 's/filename\|docdir\|directory\|path\|linkerflag\|objdir//g')"
_ld_opts_dmd="$(ld --help 2>&1 | sed -n 's/.*\(--[-a-z0-9]\{1,\}\).*/-L\1/p')"
_env_vars_dmd="$(printenv | cut -d = -f 1 | sort -u)"
COMPREPLY=()
local cur
_get_comp_words_by_ref -n = cur
local IFS=$'\t\n'
case "${cur}" in
-L-L*) # match linker paths
compopt -o nospace
_filedir_dmd "-L-L" "(/)"
;;
-L--*) # match linker options
COMPREPLY=( $( compgen -W "${_ld_opts_dmd}" -- ${cur} ) )
;;
-L*) # match linker options
local opts=$(echo -e "-L-L\n-L--")
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
;;
-*) # match dmd options
compopt -o nospace
if [[ "${cur}" == "-Dd"* ]] ;then
_filedir_dmd "-Dd" "(/)"
elif [[ "${cur}" == "-Df"* ]] ;then
_filedir_dmd "-Df" "(*)"
elif [[ "${cur}" == "-debug="* ]] ;then
cur=${cur#*=}
elif [[ "${cur}" == "-debuglib="* ]] ;then
cur=${cur#*=}
_filedir
if [ ${#COMPREPLY[@]} -eq 1 ] && [ -f ${COMPREPLY[@]} ] ;then
compopt +o nospace
fi
elif [[ "${cur}" == "-defaultlib="* ]] ;then
cur=${cur#*=}
_filedir
if [ ${#COMPREPLY[@]} -eq 1 ] && [ -f ${COMPREPLY[@]} ] ;then
compopt +o nospace
fi
elif [[ "${cur}" == "-deps="* ]] ;then
cur=${cur#*=}
_filedir
if [ ${#COMPREPLY[@]} -eq 1 ] && [ -f ${COMPREPLY[@]} ] ;then
compopt +o nospace
fi
elif [[ "${cur}" == "-Hd"* ]] ;then
_filedir_dmd "-Hd" "(/)"
elif [[ "${cur}" == "-Hf"* ]] ;then
_filedir_dmd "-Hf" "(*)"
elif [[ "${cur}" == "-I"* ]] ;then
_filedir_dmd "-I" "(/)"
elif [[ "${cur}" == "-J"* ]] ;then
_filedir_dmd "-J" "(/)"
elif [[ "${cur}" == "-od"* ]] ;then
_filedir_dmd "-od" "(/)"
elif [[ "${cur}" == "-of"* ]] ;then
_filedir_dmd "-of" "(*)"
elif [[ "${cur}" == "-version="* ]] ;then
cur=${cur#*=}
elif [[ "${cur}" == "-Xf"* ]] ;then
_filedir_dmd "-Xf" "(*)"
else
COMPREPLY=( $(compgen -W "${_dmd_opts}" -- ${cur}) )
C='\n'
L=$(echo -e "-cov${C}-fPIC${C}-gc${C}--help${C}-ignore\
${C}-inline${C}-lib${C}-m32${C}-m64${C}-man${C}-map\
${C}-noboundscheck${C}-nofloat${C}-O${C}-o-${C}-op\
${C}-profile${C}-quiet${C}-release${C}-run${C}-unittest\
${C}-vtls${C}-wi" | sed 's: ::g')
if test ${#COMPREPLY[@]} -eq 1 ;then
for I in ${L}
do
if test "${COMPREPLY[@]}" == "$I" ; then
compopt +o nospace
fi
done
fi
fi
;;
@*) # match arguments variable/file
compopt -o nospace
TMP=( $(compgen -W "${_env_vars_dmd}" -P "@" -- ${cur#@}) )
_filedir_dmd "@" "(*)"
COMPREPLY=( "${TMP[@]}" "${COMPREPLY[@]}" )
if test ${#COMPREPLY[@]} -eq 1 ;then compopt +o nospace ; fi
;;
*) # match d files
_filedir '@(d|dd|di|o|a|/)'
;;
esac
return 0
}
complete -F _dmd dmd
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
|