2014-09-09 18:29:34 +05:30
|
|
|
_xbps_parse_help() {
|
|
|
|
local IFS line word
|
|
|
|
|
|
|
|
$1 --help 2>&1 | while IFS=$'\n' read -r line; do
|
|
|
|
[[ $line == *([ $'\t'])-* ]] || continue
|
|
|
|
|
|
|
|
IFS=$' \t,='
|
|
|
|
for word in $line; do
|
|
|
|
[[ $word == -* ]] || continue
|
|
|
|
printf -- '%s\n' $word
|
|
|
|
done
|
|
|
|
done | sort | uniq
|
|
|
|
}
|
|
|
|
|
|
|
|
_xbps_all_packages() {
|
2014-09-15 12:17:36 +05:30
|
|
|
xbps-query -Rs "$1*" | sed 's/^... \([^ ]*\)-.* .*/\1/'
|
2014-09-09 18:29:34 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_xbps_installed_packages() {
|
|
|
|
xbps-query -l | sed 's/^.. \([^ ]*\)-.* .*/\1/'
|
|
|
|
}
|
|
|
|
|
|
|
|
_xbps_all_reply() {
|
|
|
|
COMPREPLY=( $( compgen -W '$(_xbps_all_packages "$1")' -- "$1") )
|
|
|
|
}
|
|
|
|
|
|
|
|
_xbps_installed_reply() {
|
|
|
|
COMPREPLY=( $( compgen -W '$(_xbps_installed_packages)' -- "$1") )
|
|
|
|
}
|
|
|
|
|
|
|
|
_xbps_complete() {
|
|
|
|
local cur prev words cword
|
|
|
|
|
|
|
|
_init_completion || return
|
|
|
|
|
|
|
|
if [[ "$cur" == -* ]]; then
|
|
|
|
COMPREPLY=( $( compgen -W '$( _xbps_parse_help "$1" )' -- "$cur") )
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2014-09-19 01:14:31 +05:30
|
|
|
local common='C|-config|r|-rootdir'
|
|
|
|
local morecommon="$common|c|-cachedir"
|
2014-09-09 18:29:34 +05:30
|
|
|
|
2014-09-15 12:54:01 +05:30
|
|
|
local modes='auto manual hold unhold'
|
|
|
|
local props='architecture
|
2014-09-15 21:58:33 +05:30
|
|
|
archive-compression-type
|
2014-09-15 12:54:01 +05:30
|
|
|
automatic-install
|
|
|
|
build-date
|
|
|
|
build-options
|
2014-09-15 21:58:33 +05:30
|
|
|
conf_files
|
2014-09-15 12:54:01 +05:30
|
|
|
conflicts
|
2014-09-15 21:58:33 +05:30
|
|
|
filename-sha256
|
|
|
|
filename-size
|
2014-09-15 12:54:01 +05:30
|
|
|
homepage
|
|
|
|
install-date
|
2014-09-15 21:58:33 +05:30
|
|
|
install-msg
|
2014-09-15 12:54:01 +05:30
|
|
|
install-script
|
|
|
|
installed_size
|
|
|
|
license
|
|
|
|
maintainer
|
|
|
|
metafile-sha256
|
|
|
|
packaged-with
|
|
|
|
pkgver
|
|
|
|
preserve
|
|
|
|
provides
|
2014-09-15 21:58:33 +05:30
|
|
|
remove-msg
|
2014-09-15 12:54:01 +05:30
|
|
|
remove-script
|
|
|
|
replaces
|
|
|
|
repository
|
|
|
|
shlib-provides
|
|
|
|
shlib-requires
|
|
|
|
short_desc
|
|
|
|
source-revisions
|
|
|
|
state'
|
|
|
|
|
2014-09-09 18:29:34 +05:30
|
|
|
case $1 in
|
|
|
|
xbps-dgraph)
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev != -@(c|o|r) ]]; then
|
2014-09-09 18:29:34 +05:30
|
|
|
_xbps_installed_reply $cur
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
xbps-install)
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev != -@($morecommon) ]]; then
|
2014-09-09 18:29:34 +05:30
|
|
|
_xbps_all_reply $cur
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
xbps-pkgdb)
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev == -@(m|-mode) ]]; then
|
2014-09-15 12:54:01 +05:30
|
|
|
COMPREPLY=( $( compgen -W "$modes" -- "$cur") )
|
2014-09-09 18:29:34 +05:30
|
|
|
return
|
|
|
|
fi
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev != -@($common) ]]; then
|
2014-09-09 18:29:34 +05:30
|
|
|
_xbps_installed_reply $cur
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
xbps-query)
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev == -@(p|-property) ]]; then
|
2014-09-15 12:54:01 +05:30
|
|
|
COMPREPLY=( $( compgen -W "$props" -- "$cur") )
|
|
|
|
return
|
|
|
|
fi
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev != -@($morecommon|o|-ownedby) ]]; then
|
2014-09-19 01:15:58 +05:30
|
|
|
local w
|
|
|
|
for w in "${words[@]}"; do
|
|
|
|
if [[ "$w" == -@(R|-repository) ]]; then
|
|
|
|
_xbps_all_reply $cur
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
_xbps_installed_reply $cur
|
2014-09-09 18:29:34 +05:30
|
|
|
return
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
xbps-reconfigure)
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev != -@($common) ]]; then
|
2014-09-09 18:29:34 +05:30
|
|
|
_xbps_installed_reply $cur
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
xbps-remove)
|
2014-09-19 01:14:31 +05:30
|
|
|
if [[ $prev != -@($morecommon) ]]; then
|
2014-09-09 18:29:34 +05:30
|
|
|
_xbps_installed_reply $cur
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
_filedir
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _xbps_complete xbps-checkvers xbps-create xbps-dgraph xbps-install \
|
|
|
|
xbps-pkgdb xbps-query xbps-reconfigure xbps-remove xbps-rindex
|