|
|
|
# EasyEngine auto complete
|
|
|
|
|
|
|
|
function ee_single()
|
|
|
|
{
|
|
|
|
for (( j=0; j<${#COMP_WORDS[@]}; j++ )); do
|
|
|
|
for (( i=0; i<${#COMPREPLY[@]}; i++ )); do
|
|
|
|
if [[ ${COMP_WORDS[COMP_CWORD-j]} == ${COMPREPLY[i]} ]]; then
|
|
|
|
rem=( ${COMP_WORDS[COMP_CWORD-j]} );
|
|
|
|
COMPREPLY=( "${COMPREPLY[@]/$rem" )
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function EE_AUTO()
|
|
|
|
{
|
|
|
|
# Get current word
|
|
|
|
local CURRENT=${COMP_WORDS[COMP_CWORD]}
|
|
|
|
|
|
|
|
# Get previous word
|
|
|
|
local PREVIOUS=${COMP_WORDS[COMP_CWORD-1]}
|
|
|
|
local PREVIOUS2=${COMP_WORDS[COMP_CWORD-2]}
|
|
|
|
local PREVIOUS3=${COMP_WORDS[COMP_CWORD-3]}
|
|
|
|
|
|
|
|
# List of suggested words
|
|
|
|
case "$PREVIOUS" in
|
|
|
|
|
|
|
|
# List of suggested words
|
|
|
|
easyengine|ee)
|
|
|
|
COMPREPLY=( $(compgen -W '$(echo version help info update; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
stack)
|
|
|
|
COMPREPLY=( $( compgen -W '$(echo purge status stop start reload restart; command find /usr/local/lib/easyengine/modules/stack -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
install|remove|purge)
|
|
|
|
COMPREPLY=( $( compgen -W '$(echo mail all web mailscanner; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
site)
|
|
|
|
COMPREPLY=( $( compgen -W '$(echo disable enable list show; command find /usr/local/lib/easyengine/modules/site -maxdepth 1 -type d -printf "%P " 2> /dev/null; cd /usr/local/lib/easyengine/modules/site/; find -type f | grep site | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null)' -- $CURRENT ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
list)
|
|
|
|
COMPREPLY=( $( compgen -W "enable available" -- $CURRENT ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
info|enable|edit|show|delete)
|
|
|
|
if [ "$PREVIOUS2" = "site" ]; then
|
|
|
|
COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)' -- $CURRENT ) )
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
disable)
|
|
|
|
COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)' -- $CURRENT ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--wpsubdir|--wpsubdomain)
|
|
|
|
COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
debug)
|
|
|
|
COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--nginx|--rewrite|--php|--fpm|--mysql)
|
|
|
|
COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) )
|
|
|
|
ee_single
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--wp)
|
|
|
|
if [ "$PREVIOUS3" = "create" ]; then
|
|
|
|
COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) )
|
|
|
|
else
|
|
|
|
COMPREPLY=( $(compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | grep -v wp | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) )
|
|
|
|
ee_single
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
--stop)
|
|
|
|
|
|
|
|
COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)' -- $CURRENT ) )
|
|
|
|
ee_single
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
secure)
|
|
|
|
COMPREPLY=( $( compgen -W '$( cd /usr/local/lib/easyengine/modules/secure; find -type f | grep secure | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT ) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
if [ "$PREVIOUS2" = "create" ]; then
|
|
|
|
COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) )
|
|
|
|
elif [ "$PREVIOUS2" = "delete" ]; then
|
|
|
|
COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) )
|
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -F EE_AUTO ee easyengine
|