mscs/mscs.completion

57 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-03-03 19:36:20 -07:00
MSCS=/usr/bin/mscs
2015-03-03 19:36:20 -07:00
_mscs() {
local OPTS WORLDS
COMPREPLY=()
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
OPTS="
2014-02-08 12:35:13 -07:00
backup console create delete disable enable force-restart force-stop list
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
"
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=$($MINECRAFT_SERVER list stopped)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
2014-12-20 23:28:54 -07:00
stop|force-stop|restart|force-restart|send|console)
WORLDS=$($MINECRAFT_SERVER list running)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
2013-12-07 12:26:01 -07:00
delete|remove|disable|status|show|sync|send|watch|logrotate| \
backup|map|overviewer|list-backups|restore-backup)
WORLDS=$($MINECRAFT_SERVER list enabled)
COMPREPLY=($(compgen -W "$WORLDS" -- ${COMP_WORDS[COMP_CWORD]}))
;;
enable)
WORLDS=$($MINECRAFT_SERVER list 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=$($MINECRAFT_SERVER list-backups "${COMP_WORDS[COMP_CWORD-1]}")
COMPREPLY=($(compgen -W "$BACKUPS" -- "${COMP_WORDS[COMP_CWORD]}"))
;;
*)
;;
esac
fi
return 0
}
2015-03-03 19:36:20 -07:00
complete -F _mscs $MSCS