mirror of
https://github.com/MinecraftServerControl/mscs.git
synced 2024-11-15 14:58:18 -07:00
c790ae3c8b
This is to reflect that some operations can now be applied to any available world even if not enabled.
65 lines
1.8 KiB
Plaintext
65 lines
1.8 KiB
Plaintext
MSCS=mscs
|
|
|
|
list_worlds() {
|
|
$MSCS ls $1 | sed -n '/:/{s/^ *//;s/:.*$//;p}'
|
|
}
|
|
|
|
_mscs() {
|
|
local OPTS WORLDS
|
|
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 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)
|
|
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 $MSCS
|