-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdcm.sh
66 lines (59 loc) · 1.65 KB
/
dcm.sh
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
# Entry point of the dcm command
dcm() {
local OS=$(uname -s)
local ARCH=$(uname -m)
local BIN=$DCM_DIR/bin
if [[ "$OS" == "Darwin" ]] && [[ "$ARCH" == "arm64" ]]; then
BIN=$BIN/dcm-darwin-arm64
elif [[ "$OS" == "Darwin" ]] && [[ "$ARCH" == "x86_64" ]]; then
BIN=$BIN/dcm-darwin-amd64
elif [[ "$OS" == "Linux" ]] && [[ "$ARCH" == "x86_64" ]]; then
BIN=$BIN/dcm-linux-amd64
elif [[ "$OS" == "FreeBSD" ]] && [[ "$ARCH" == "x86_64" ]]; then
BIN=$BIN/dcm-freebsd-amd64
elif [[ "$OS" == "CYGWIN_NT-6.1" ]] && [[ "$ARCH" == "x86_64" ]]; then
BIN=$BIN/dcm-windows-amd64.exe
else
>&2 echo "Sorry, your OS ($OS) and Arch ($ARCH) is not currently supported by DCM." && \
echo "Please submit your issue at /~https://github.com/beanworks/dcm/issues"
return 1
fi
case "$1" in
"goto" | "gt" | "cd" )
cd $($BIN dir ${@:2})
;;
"unload" | "ul" )
unset -f dcm > /dev/null 2>&1
unset DCM_DIR DCM_PROJECT > /dev/null 2>&1
;;
* )
$BIN ${@}
;;
esac
}
# DCM command autocomplete handler
_dcm_complete() {
local cur=${COMP_WORDS[COMP_CWORD]}
local use=""
case $COMP_CWORD in
1)
use="help setup run build shell purge branch goto update unload"
;;
2)
local prev_word=${COMP_WORDS[1]}
case $prev_word in
run|r)
use="execute init build start stop restart up"
;;
purge|rm)
use="images containers all"
;;
shell|sh|branch|br|goto|gt|cd|update|u)
use=`dcm list`
;;
esac
;;
esac
COMPREPLY=( $( compgen -W "$use" -- $cur ) )
}
complete -o default -F _dcm_complete dcm