-
Notifications
You must be signed in to change notification settings - Fork 110
/
rtt_completion
148 lines (135 loc) · 3.69 KB
/
rtt_completion
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
138
139
140
141
142
143
144
145
146
147
148
# Notes
_rosetta_complete_func() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
local cmd=''
local n=${#COMP_WORDS[@]}
if [ $n -gt 1 ]; then
cmd=${COMP_WORDS[1]}
fi
case "${cmd}" in
compile) # #####################
opts0="--phase --build-type --enable-gmssl"
opts0+=" --enable-all --enable-protocol-mpc-securenn"
opts0+=" --enable-protocol-mpc-helix --enable-protocol-psi --enable-protocol-zk --enable-128bit --enable-tests"
arr_opts=(${opts0})
opts=""
for ((i = 0; i < ${#arr_opts[@]}; i++)); do
f=0
for ((c = 1; c <= ${#COMP_WORDS[@]}; c++)); do
if [ "${COMP_WORDS[c]}" = "${arr_opts[i]}" ]; then
f=1
break
fi
done
if [ $f -eq 0 ]; then
opts+=" ${arr_opts[i]}"
fi
done
case "${prev}" in
--help)
return 0
;;
--phase)
opts="modules py all"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
--build-type)
opts="Release Debug"
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
test) # #####################
opts0="all"
opts0+=" common netio mpc mpc-securenn mpc-helix psi zk"
opts0+=" op gradop spass dpass other"
arr_opts=(${opts0})
opts=""
for ((i = 0; i < ${#arr_opts[@]}; i++)); do
f=0
for ((c = 1; c <= ${#COMP_WORDS[@]}; c++)); do
if [ "${COMP_WORDS[c]}" = "${arr_opts[i]}" ]; then
f=1
break
fi
done
if [ $f -eq 0 ]; then
opts+=" ${arr_opts[i]}"
fi
done
case "${prev}" in
--help | all)
return 0
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
perf) # #####################
opts0="all"
opts0+=" mpc mpc-securenn mpc-helix"
arr_opts=(${opts0})
opts=""
for ((i = 0; i < ${#arr_opts[@]}; i++)); do
f=0
for ((c = 1; c <= ${#COMP_WORDS[@]}; c++)); do
if [ "${COMP_WORDS[c]}" = "${arr_opts[i]}" ]; then
f=1
break
fi
done
if [ $f -eq 0 ]; then
opts+=" ${arr_opts[i]}"
fi
done
case "${prev}" in
--help | all)
return 0
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
install) # #####################
return 0
# todo
opts="--help"
case "${prev}" in
--help)
return 0
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
clean) # #####################
return 0
# todo
opts="--help"
case "${prev}" in
--help)
return 0
;;
esac
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
;;
--help | --version) # #####################
return 0 ;;
esac
cmd_opts="compile install test perf clean"
if [[ ${cur} == * ]]; then
cmd=''
COMPREPLY=($(compgen -W "${cmd_opts}" -- ${cur}))
return 0
fi
return 0
}
complete -F _rosetta_complete_func ./rosetta.sh