Commit 096670ce authored by Иван Мажукин's avatar Иван Мажукин Committed by Vitaly Lipatov

bash completion update (eterbug #17251)

parent 9779f803
...@@ -2,19 +2,69 @@ ...@@ -2,19 +2,69 @@
# This completes on a list of all available services for the # This completes on a list of all available services for the
# 'serv' command, followed by that script's available commands # 'serv' command, followed by that script's available commands
# #
__eepm_list_commands() __eepm_list_commands()
{ {
COMPREPLY=( $(echo "install remove") ) COMPREPLY=( $(echo "install remove play update full-upgrade") )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
}
__eepm_list_installed_packages()
{
COMPREPLY=( $( epm list --installed --quiet --short) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
} }
__eepm_list_available_packages() __eepm_list_available_packages()
{ {
COMPREPLY=( $( cat /var/lib/eepm/available-packages 2>/dev/null ) ) COMPREPLY=( $( cat /var/lib/eepm/available-packages 2>/dev/null ) )
#local USLIST=$(serv ${prev##*/} usage 2>/dev/null | sed -e "y/|/ /" -ne "s/^.*\(u\|U\|msg_u\)sage.*{\(.*\)}.*$/\2/p")
COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) )
#COMPREPLY=( $( compgen -W '$USLIST' -- "$cur" ) ) }
__eepm_list_available_packages_play()
{
COMPREPLY=( $( epm play --list-all --short ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.sh}' -- "$cur" ) )
}
__eepm_complete_args(){
COMPREPLY=($(compgen -W '-h --help -v --version --verbose --debug
--skip-installed --skip-missed --show-command-only --quiet --silent --nodeps
--force --noremove --no-remove --no-stdin --inscript
--dry-run --simulate --just-print --no-act --short --direct --repack --norepack --install
--scripts --noscripts --save-only --put-to-repo= --download-only --url --sort -y --auto
--assumeyes --non-interactive --disable-interactivity --interactive --force-yes' -- "$cur"))
}
__eepm_complete_commands() {
local special i
for ((i = 1; i < ${#COMP_WORDS[@]} - 1; i++)); do
if [[ ${COMP_WORDS[i]} == @(install|remove|play) ]]; then
special=${COMP_WORDS[i]}
break
fi
done
if [[ -v special ]]; then
case $special in
install)
__eepm_list_available_packages
return 0
;;
remove)
__eepm_list_installed_packages
return 0
;;
play)
__eepm_list_available_packages_play
return 0
;;
esac
else
__eepm_list_commands
fi
} }
...@@ -25,26 +75,25 @@ __eepm() ...@@ -25,26 +75,25 @@ __eepm()
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref cur prev _get_comp_words_by_ref cur prev
[[ ${COMP_WORDS[0]} != "epm" ]] && return 0 case "${COMP_WORDS[0]}" in
epm)
# don't complete past 2nd token __eepm_complete_commands ;;
#[ $COMP_CWORD -gt 2 ] && return 0 epmi)
__eepm_list_available_packages ;;
epme)
__eepm_list_installed_packages ;;
epmp)
__eepm_list_available_packages_play ;;
*)
return 0 ;;
esac
if [[ $COMP_CWORD -eq 1 && $prev == "epm" ]]; then if [[ $cur == -* ]]; then
__eepm_list_commands __eepm_complete_args
return 0 return 0
fi fi
if [[ $COMP_CWORD -eq 2 && $prev == "install" ]]; then
__eepm_list_available_packages
return 0
fi
if [[ $COMP_CWORD -eq 2 && $prev == "remove" ]]; then
__eepm_list_available_packages
return 0
fi
return 0
} && } &&
complete -F __eepm epm
# . "/usr/share/bash-completion/bash_completion"
complete -F __eepm epm epmi epme epmp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment