Advertisement
2lame2blame

wrench.bash-autocompletion

Jun 4th, 2014
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.88 KB | None | 0 0
  1. # wrench bash auto-completion
  2. # Add this text to your ~/.bash_completion file.
  3. # Be sure to set APPDIR, SQLDBFILE, and SQLCMD exactly as they are in wrench.
  4.  
  5. _wrench()
  6. {
  7.     local cur prev opts base APPDIR SQLDBFILE SQLCMD LIST_INSTALLS
  8.     COMPREPLY=()
  9.     cur="${COMP_WORDS[COMP_CWORD]}"
  10.     prev="${COMP_WORDS[COMP_CWORD-1]}"
  11.  
  12.     opts="autocleanup autoupdate bootstart console delink install list listplayers lockdown-master reconfig relink rename restart restartnow setup showconfig start status stop stopall stopnow uninstall unlock-master update updatenow update-validate update-validatenow gametype"
  13.  
  14.     # APPDIR, SQLDBFILE, and SQLCMD should be the same as what is set in wrench. Change here as needed.
  15.     APPDIR=~/srcds
  16.     SQLDBFILE=$APPDIR/wrench.db
  17.     SQLCMD="sqlite3 -batch -list -noheader $SQLDBFILE"
  18.  
  19.     case "${prev}" in
  20.     # All installation types.
  21.         showconfig|reconfig|rename)
  22.             local LIST_INSTALLS=$($SQLCMD "select INSTALLID from inst;")
  23.             COMPREPLY=( $(compgen -W "${LIST_INSTALLS}" -- ${cur}) )
  24.             return 0
  25.         ;;
  26.     # Runnable installation types (linked and standalone).
  27.         start|stop|stopnow|restart|restartnow|console|status|relink|delink)
  28.             local LIST_RUNNABLE=$($SQLCMD "select INSTALLID from inst where INSTTYPE='linked' or INSTTYPE='standalone';")
  29.             COMPREPLY=( $(compgen -W "${LIST_RUNNABLE}" -- ${cur}) )
  30.             return 0
  31.         ;;
  32.     # Master installation types.
  33.         lockdown-master|unlock-master|update|updatenow|update-validate|update-validatenow)
  34.             local LIST_MASTERS=$($SQLCMD "select INSTALLID from inst where INSTTYPE='master';")
  35.             COMPREPLY=( $(compgen -W "${LIST_MASTERS}" -- ${cur}) )
  36.             return 0
  37.         ;;
  38.     # Game type actions.
  39.         gametype)
  40.             local LIST_GAMETYPE_ACTIONS="add change delete"
  41.             COMPREPLY=( $(compgen -W "${LIST_GAMETYPE_ACTIONS}" -- ${cur}) )
  42.             return 0
  43.         ;;
  44.         *)
  45.         ;;
  46.     esac
  47.  
  48.     COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
  49.     return 0
  50. }
  51. complete -F _wrench wrench
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement