-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathyacx-completion.bash
More file actions
24 lines (21 loc) · 915 Bytes
/
yacx-completion.bash
File metadata and controls
24 lines (21 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
_yacx() {
COMPREPLY=()
local word="${COMP_WORDS[COMP_CWORD]}"
if [ "$COMP_CWORD" -eq 1 ]; then
# COMPREPLY=( $(compgen -W "$(./yacx.sh commands)" -- "$word") )
COMPREPLY=( $(compgen -W "execute-java execute-scala build-java build-scala" -- "$word") )
elif [ "$COMP_CWORD" -eq 2 ]; then
local words=("${COMP_WORDS[@]}")
unset words[0]
unset words[$COMP_CWORD]
if [ "${words[@]}" == "execute-java" ]; then
local completions=$(find examples/java -type f -iname "Example*.java" -exec basename '{}' \; | sed 's/\.java$//1')
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
elif [ "${words[@]}" == "execute-scala" ]; then
local completions=$(find examples/scala -type f -iname "Example*.scala" -exec basename '{}' \; | sed 's/\.scala$//1')
COMPREPLY=( $(compgen -W "$completions" -- "$word") )
fi
fi
}
complete -F _yacx ./yacx.sh