-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.bash
More file actions
39 lines (36 loc) · 1.27 KB
/
Copy pathsetup.bash
File metadata and controls
39 lines (36 loc) · 1.27 KB
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
BASEDIR=$(dirname "$0")
export PYTHONPATH=$BASEDIR:$BASEDIR/examples:$PYTHONPATH
export PATH=$BASEDIR/examples/scripts:$PATH
function _complete_rocktask {
local arg opts
COMPREPLY=()
arg="${COMP_WORDS[COMP_CWORD]}"
if [[ $COMP_CWORD == 1 ]]; then
opts="list info start stop cleanup configure in out echo"
COMPREPLY=($(compgen -W "$opts" -- ${arg}))
elif [[ $COMP_CWORD == 2 ]]; then
case ${COMP_WORDS[1]} in
info|start|stop|cleanup|configure|in|out|echo)
if [[ ${arg} =~ \-\-.* ]]; then
opts="--help"
else
# complete on task name
opts=`rocktask list 2> /dev/null`
fi
COMPREPLY=($(compgen -W "$opts" -- ${arg}))
;;
list)
if [[ ${arg} =~ \-\-.* ]]; then
opts="--state --help"
fi
COMPREPLY=($(compgen -W "$opts" -- ${arg}))
;;
esac
elif [[ $COMP_CWORD == 3 ]]; then
if [[ ${COMP_WORDS[1]} == 'echo' ]]; then
opts=`rocktask out ${COMP_WORDS[2]} 2> /dev/null`
COMPREPLY=($(compgen -W "$opts" -- ${arg}))
fi
fi
}
complete -F "_complete_rocktask" "rocktask"