2011-11-01 22:14:45 +02:00
|
|
|
# bash completion for cpan2dist -*- shell-script -*-
|
2009-01-19 21:56:42 +01:00
|
|
|
|
|
|
|
_cpan2dist()
|
|
|
|
{
|
2011-04-20 14:42:30 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2009-01-19 21:56:42 +01:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
case $prev in
|
|
|
|
--format)
|
|
|
|
# should remove ":" from COMP_WORDBREAKS, but doesn't work (?)
|
|
|
|
COMPREPLY=( $( compgen -W '$(perl -MCPANPLUS::Dist -e \
|
|
|
|
"print map { \"\$_\n\" } CPANPLUS::Dist->dist_types")' \
|
|
|
|
-- "$cur" ) )
|
|
|
|
return 0
|
|
|
|
;;
|
2009-11-22 11:43:26 +01:00
|
|
|
--banlist|--ignorelist|--modulelist|--logfile)
|
2009-10-04 19:42:50 +02:00
|
|
|
_filedir
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
2009-01-19 21:56:42 +01:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
if [[ "$cur" == -* ]]; then
|
2011-04-29 12:26:46 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
else
|
2011-04-20 14:42:30 +03:00
|
|
|
local cpandirs=( "$HOME/.cpanplus/" "$HOME/.cpan/source/modules/" )
|
|
|
|
local packagelist
|
2009-10-04 19:42:50 +02:00
|
|
|
for dir in ${cpandirs[@]}; do
|
2009-11-23 20:08:52 +02:00
|
|
|
[[ -d "$dir" && -r "$dir/02packages.details.txt.gz" ]] && \
|
2009-10-04 19:42:50 +02:00
|
|
|
packagelist="$dir/02packages.details.txt.gz"
|
|
|
|
done
|
2011-10-23 11:13:50 +03:00
|
|
|
[[ $packagelist ]] && COMPREPLY=( $( zgrep "^${cur//-/::}" \
|
|
|
|
$packagelist 2>/dev/null | awk '{print $1}' | sed -e 's/::/-/g' ) )
|
2009-10-04 19:42:50 +02:00
|
|
|
fi
|
2009-01-19 21:56:42 +01:00
|
|
|
} &&
|
2009-10-22 12:04:29 +03:00
|
|
|
complete -F _cpan2dist -o default cpan2dist
|
2009-10-01 20:54:51 +03:00
|
|
|
|
2009-10-04 19:42:50 +02:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|