Blame | Last modification | View Log | RSS feed
# main function bound to scl command_scl(){local cur actions cur_action collectionsCOMPREPLY=()cur="${COMP_WORDS[COMP_CWORD]}"actions="enable run load unload list-collections list-packages man register deregister --help"collections=`scl list-collections`# Complete action namesif ((COMP_CWORD == 1)); thenCOMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )return 0;fi# If there is command or separator in arguments then stop completitionif ((COMP_CWORD > 3)); thenfor word in "${COMP_WORDS[@]}"; doif [[ ${word} == \'* || ${word} == \"* || ${word} == "--" ]] ; thenreturn 0fidonefi# Complete one or none action argumentif ((COMP_CWORD >= 2)); thencur_action="${COMP_WORDS[1]}"case "$cur_action" in# No argumentlist-collections|list-enabled|--help)return 0;;# Argument is collection namelist-packages|man)if ((COMP_CWORD == 2)); thenCOMPREPLY=( $(compgen -W "$collections" -- ${cur}) )fireturn 0;;# Argument is collection name or "-f" or "--force"deregister)if ((COMP_CWORD == 2)); thenCOMPREPLY=( $(compgen -W "$collections --force -f" -- ${cur}))fiif [ "$COMP_CWORD" -eq 3 -a "(" "${COMP_WORDS[2]}" == "--force" -o "${COMP_WORDS[2]}" == "-f" ")" ]; thenCOMPREPLY=( $(compgen -W "$collections" -- ${cur}))fireturn 0;;# Argument is directoryregister)compopt -o plusdirsif ((COMP_CWORD == 2)); thenCOMPREPLY=( $(compgen -A directory -- ${cur}) )fireturn 0;;# Arguments are collections or "-x" or "--exec"run|enable)if ((COMP_CWORD == 2)); thenCOMPREPLY=( $(compgen -W "$collections -x --exec" -- ${cur}) )elseCOMPREPLY=( $(compgen -W "$collections" -- ${cur}) )fireturn 0;;# Arguments are collectionsload|unload)COMPREPLY=( $(compgen -W "$collections" -- ${cur}) )return 0;;*);;esacfi}# bind the scl command to the _scl function for completioncomplete -F _scl scl