-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoenv-completion
More file actions
57 lines (44 loc) · 1.35 KB
/
oenv-completion
File metadata and controls
57 lines (44 loc) · 1.35 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/bash
function _oenv()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev1="${COMP_WORDS[COMP_CWORD-1]}"
prev2="${COMP_WORDS[COMP_CWORD-2]}"
prev3="${COMP_WORDS[COMP_CWORD-3]}"
opts="update workspace runtime --version --help -h -?"
# Update
if [ "${prev1}" == "update" ]; then
opts=check
elif [[ "${prev2}" == "update" && "${prev1}" == "check" ]]; then
opts="-y --yes"
# Workspace
elif [ "${prev1}" == "workspace" ]; then
opts="install show"
elif [ "${prev2}" == "workspace" ]; then
if [ "${prev1}" == "install" ]; then
opts="-ws --ws-path --register-only"
elif [ "${prev1}" == "show" ]; then
opts="-ws --ws-path"
fi
# Runtime
elif [ "${prev1}" == "runtime" ]; then
opts="create repair"
elif [[ "${prev2}" == "runtime" && "${prev1}" == "create" ]]; then
opts="-p --cache-path -ws --ws-path -s --save -f --force"
# Help
elif [[ "${prev1}" == "--help" || ${prev1} == "-h" || "${prev1}" == "-?" ]]; then
opts="update workspace runtime"
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _oenv oenv
function oenv() {
if [ $# -eq 1 ] && [ "$1" == "workspace" ]; then
orientroot
return 0
fi
command oenv $@
}