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

bash completion update (eterbug #17251)

parent 9779f803
...@@ -5,46 +5,95 @@ ...@@ -5,46 +5,95 @@
# #
__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()
__eepm()
{ {
local cur prev COMPREPLY=( $( epm play --list-all --short ) )
COMPREPLY=( $( compgen -W '${COMPREPLY[@]%.sh}' -- "$cur" ) )
COMPREPLY=() }
_get_comp_words_by_ref cur prev
[[ ${COMP_WORDS[0]} != "epm" ]] && return 0 __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"))
}
# don't complete past 2nd token __eepm_complete_commands() {
#[ $COMP_CWORD -gt 2 ] && return 0
if [[ $COMP_CWORD -eq 1 && $prev == "epm" ]]; then local special i
__eepm_list_commands for ((i = 1; i < ${#COMP_WORDS[@]} - 1; i++)); do
return 0 if [[ ${COMP_WORDS[i]} == @(install|remove|play) ]]; then
special=${COMP_WORDS[i]}
break
fi fi
done
if [[ $COMP_CWORD -eq 2 && $prev == "install" ]]; then if [[ -v special ]]; then
case $special in
install)
__eepm_list_available_packages __eepm_list_available_packages
return 0 return 0
fi ;;
remove)
__eepm_list_installed_packages
return 0
;;
if [[ $COMP_CWORD -eq 2 && $prev == "remove" ]]; then play)
__eepm_list_available_packages __eepm_list_available_packages_play
return 0 return 0
;;
esac
else
__eepm_list_commands
fi fi
}
__eepm()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case "${COMP_WORDS[0]}" in
epm)
__eepm_complete_commands ;;
epmi)
__eepm_list_available_packages ;;
epme)
__eepm_list_installed_packages ;;
epmp)
__eepm_list_available_packages_play ;;
*)
return 0 ;;
esac
if [[ $cur == -* ]]; then
__eepm_complete_args
return 0 return 0
fi
} && } &&
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