-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathmscs.completion
More file actions
63 lines (58 loc) · 1.87 KB
/
mscs.completion
File metadata and controls
63 lines (58 loc) · 1.87 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
57
58
59
60
61
62
63
list_worlds() {
$MSCS ls $1 | sed -n '/:/{s/^ *//;s/:.*$//;p}'
}
_mscs() {
local OPTS WORLDS
MSCS="$1"
COMPREPLY=()
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
OPTS="
backup console create delete disable enable force-restart force-stop list
list-backups logrotate map new overviewer remove restart restore-backup
broadcast send show start status stop sync update force-update watch usage
"
LIST_OPTS="enabled disabled running stopped"
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=($(compgen -W "$OPTS" -- ${COMP_WORDS[COMP_CWORD]}))
elif [ $COMP_CWORD -eq 2 ]; then
case ${COMP_WORDS[COMP_CWORD-1]} in
start)
WORLDS=$(list_worlds stopped)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
stop|force-stop|restart|force-restart|send|console)
WORLDS=$(list_worlds running)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
disable|sync|send|watch|logrotate|backup|map|overviewer|\
list-backups|restore-backup|update|force-update)
WORLDS=$(list_worlds enabled)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
status|show|remove|delete)
WORLDS=$(list_worlds)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
enable)
WORLDS=$(list_worlds disabled)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
ls|list)
COMPREPLY=($(compgen -W "$LIST_OPTS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
*)
;;
esac
elif [ $COMP_CWORD -eq 3 ]; then
case ${COMP_WORDS[COMP_CWORD-2]} in
restore-backup)
BACKUPS=$($MSCS list-backups "${COMP_WORDS[COMP_CWORD-1]}")
COMPREPLY=($(compgen -W "$BACKUPS" -- "${COMP_WORDS[COMP_CWORD]}"))
;;
*)
;;
esac
fi
return 0
}
complete -F _mscs msctl mscs