-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathballerina-completion.bash
40 lines (34 loc) · 1.03 KB
/
ballerina-completion.bash
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
#/usr/bin/env bash
_ballerina() {
local cur prev words cword
_init_completion -n : || return
if [ "${#words[@]}" == 2 ]; then
COMPREPLY=($(compgen -W "new add build run test doc clean format pull push search encrypt grpc openapi version dist update" -- "$cur"))
return
fi
if [ "${#words[@]}" == 3 ]; then
case $prev in
run|build|doc|format)
if [ -f Ballerina.toml ]; then
pushd src > /dev/null
_filedir
popd > /dev/null
elif [ $prev == 'run' ]; then
_filedir 'bal|jar'
else
_filedir 'bal'
fi
return
;;
test|push)
if [ -f Ballerina.toml ]; then
pushd src > /dev/null
_filedir
popd > /dev/null
fi
return
;;
esac
fi
}
complete -F _ballerina ballerina