2015-03-25 20:29:50 -07:00
|
|
|
MSCS=mscs
|
2013-12-02 19:29:18 -07:00
|
|
|
|
2015-07-07 15:05:40 -07:00
|
|
|
list_worlds() {
|
|
|
|
$MSCS ls $1 | sed -n '/:/{s/^ *//;s/:.*$//;p}'
|
|
|
|
}
|
|
|
|
|
2015-03-03 19:36:20 -07:00
|
|
|
_mscs() {
|
2014-09-01 12:33:44 -07:00
|
|
|
local OPTS WORLDS
|
2013-12-02 14:13:18 -07:00
|
|
|
COMPREPLY=()
|
2014-09-01 12:33:44 -07:00
|
|
|
|
|
|
|
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
|
2013-11-14 20:25:01 -07:00
|
|
|
|
2013-12-07 09:44:13 -07:00
|
|
|
OPTS="
|
2014-02-08 12:35:13 -07:00
|
|
|
backup console create delete disable enable force-restart force-stop list
|
2014-09-01 12:33:44 -07:00
|
|
|
list-backups logrotate map new overviewer remove restart restore-backup
|
2015-03-03 19:34:35 -07:00
|
|
|
broadcast send show start status stop sync update watch usage
|
2013-12-07 09:44:13 -07:00
|
|
|
"
|
|
|
|
|
|
|
|
LIST_OPTS="enabled disabled running stopped"
|
2013-11-14 20:25:01 -07:00
|
|
|
|
2013-12-02 14:13:18 -07:00
|
|
|
if [ $COMP_CWORD -eq 1 ]; then
|
2014-09-01 12:33:44 -07:00
|
|
|
COMPREPLY=($(compgen -W "$OPTS" -- ${COMP_WORDS[COMP_CWORD]}))
|
|
|
|
elif [ $COMP_CWORD -eq 2 ]; then
|
|
|
|
case ${COMP_WORDS[COMP_CWORD-1]} in
|
2013-12-07 09:44:13 -07:00
|
|
|
start)
|
2015-07-07 15:05:40 -07:00
|
|
|
WORLDS=$(list_worlds stopped)
|
2014-09-01 12:33:44 -07:00
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
|
2013-12-07 09:44:13 -07:00
|
|
|
;;
|
2014-12-20 23:28:54 -07:00
|
|
|
stop|force-stop|restart|force-restart|send|console)
|
2015-07-07 15:05:40 -07:00
|
|
|
WORLDS=$(list_worlds running)
|
2014-09-01 12:33:44 -07:00
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
|
2013-12-07 09:44:13 -07:00
|
|
|
;;
|
2013-12-07 12:26:01 -07:00
|
|
|
delete|remove|disable|status|show|sync|send|watch|logrotate| \
|
2014-09-01 12:33:44 -07:00
|
|
|
backup|map|overviewer|list-backups|restore-backup)
|
2015-07-07 15:05:40 -07:00
|
|
|
WORLDS=$(list_worlds enabled)
|
2014-09-01 12:33:44 -07:00
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
|
2013-12-07 09:44:13 -07:00
|
|
|
;;
|
|
|
|
enable)
|
2015-07-07 15:05:40 -07:00
|
|
|
WORLDS=$(list_worlds disabled)
|
2014-09-01 12:33:44 -07:00
|
|
|
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
|
2013-12-02 14:13:18 -07:00
|
|
|
;;
|
2013-12-07 09:44:13 -07:00
|
|
|
ls|list)
|
2014-09-01 12:33:44 -07:00
|
|
|
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)
|
2015-03-25 20:29:50 -07:00
|
|
|
BACKUPS=$($MSCS list-backups "${COMP_WORDS[COMP_CWORD-1]}")
|
2014-09-01 12:33:44 -07:00
|
|
|
COMPREPLY=($(compgen -W "$BACKUPS" -- "${COMP_WORDS[COMP_CWORD]}"))
|
2013-12-07 09:44:13 -07:00
|
|
|
;;
|
2013-12-02 14:13:18 -07:00
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
return 0
|
2013-11-14 20:25:01 -07:00
|
|
|
}
|
2015-03-03 19:36:20 -07:00
|
|
|
complete -F _mscs $MSCS
|