mscs/mscs.completion

61 lines
1.7 KiB
Plaintext
Raw Normal View History

2015-03-25 20:29:50 -07:00
MSCS=mscs
list_worlds() {
$MSCS ls $1 | sed -n '/:/{s/^ *//;s/:.*$//;p}'
}
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=$(list_worlds 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=$(list_worlds 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=$(list_worlds enabled)
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)
2015-03-25 20:29:50 -07:00
BACKUPS=$($MSCS 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