Alien-SVN
view release on metacpan or search on metacpan
src/subversion/tools/client-side/bash_completion view on Meta::CPAN
# no ':' so only suggest prefixes?
local seen= n=0 last= c=
for c in ${allProps[@]%:*} ; do
# do not put the same prefix twice...
if [[ $c == $cur* && ( ! $seen || $c != @($seen) ) ]]
then
let n++
last=$c
choices="$choices $c:"
if [[ $seen ]]
then
seen="$seen|$c*"
else
seen="$c*"
fi
fi
done
# supply two choices to force a partial completion and a beep
[[ $n -eq 1 ]] && choices="$last:1 $last:2"
fi
COMPREPLY=( $( compgen -W "$choices" -- $cur ) )
return 0
fi
# force mandatory --revprop option on revision properties
if [[ $isRevProp && ! $hasRevPropOpt ]]
then
COMPREPLY=( $( compgen -W '--revprop' -- $cur ) )
return 0
fi
# force mandatory --revision option on revision properties
if [[ $isRevProp && $hasRevPropOpt && ! $hasRevisionOpt ]]
then
COMPREPLY=( $( compgen -W '--revision' -- $cur ) )
return 0
fi
# possible completion when setting property values
if [[ $isPsCmd && $prop && ( ! $val || $stat = 'val' ) ]]
then
# ' is a reminder for an arbitrary value
local values="\' --file"
case $prop in
svn:keywords)
# just a subset?
values="Id Rev URL Date Author Header \' $SVN_BASH_KEYWORDS"
;;
svn:executable|svn:needs-lock)
# hmmm... canonical value * is special to the shell.
values='\\*'
;;
svn:eol-style)
values='native LF CR CRLF'
;;
svn:mime-type)
# could read /etc/mime.types if available. overkill.
values="text/ text/plain text/html text/xml text/rtf
image/ image/png image/gif image/jpeg image/tiff
audio/ audio/midi audio/mpeg
video/ video/mpeg video/mp4
application/ application/octet-stream
$SVN_BASH_MIME_TYPE"
;;
esac
COMPREPLY=( $( compgen -W "$values" -- $cur ) )
# special case for --file... return even if within an option
[[ ${COMPREPLY} ]] && return 0
fi
# maximum number of additional arguments expected in various forms
case $cmd in
merge)
nExpectArgs=3
;;
mergeinfo)
nExpectArgs=1
;;
copy|cp|move|mv|rename|ren|export|import)
nExpectArgs=2
;;
switch|sw)
[[ ! $hasRelocateOpt ]] && nExpectArgs=2
;;
help|h)
nExpectArgs=0
;;
--version)
nExpectArgs=0
;;
esac
# the maximum number of arguments is reached for a command
if [[ $nExpectArgs && $nargs -gt $nExpectArgs ]]
then
# some way to tell 'no completion at all'... is there a better one?
# Do not say 'file completion' here.
echo -en "\a"
COMPREPLY=( '' )
return 0
fi
# if not typing an option,
# then fallback on filename expansion...
if [[ $cur != -* || $stat = 'onlyarg' ]] ; then
# do we allow possible expensive completion here?
if [[ $SVN_BASH_COMPL_EXT == *svnstatus* ]] ; then
# build status command and options
# "--quiet" removes 'unknown' files
local status='svn status --non-interactive'
[[ $SVN_BASH_COMPL_EXT == *recurse* ]] || \
status="$status --non-recursive"
# I'm not sure that it can work with externals in call cases
# the output contains translatable sentences (even with quiet)
( run in 1.530 second using v1.01-cache-2.11-cpan-2398b32b56e )