aboutsummaryrefslogtreecommitdiff
path: root/Completion/Unix/Command/_subversion
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2003-08-22 14:39:49 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2003-08-22 14:39:49 +0000
commitc25a63a02f081bcf0adc47ba527f624fc411d5cf (patch)
treea573a0d42bd7b9df65106e25c509f829e3dd613b /Completion/Unix/Command/_subversion
parentebcd3c0da3f0bd8796a2da227f8aa3693d12d74c (diff)
downloadzsh-c25a63a02f081bcf0adc47ba527f624fc411d5cf.tar.gz
zsh-c25a63a02f081bcf0adc47ba527f624fc411d5cf.tar.xz
zsh-c25a63a02f081bcf0adc47ba527f624fc411d5cf.zip
merge changes back from 4.1
Diffstat (limited to 'Completion/Unix/Command/_subversion')
-rw-r--r--Completion/Unix/Command/_subversion116
1 files changed, 116 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
new file mode 100644
index 000000000..4fea4f72e
--- /dev/null
+++ b/Completion/Unix/Command/_subversion
@@ -0,0 +1,116 @@
+#compdef svn svnadmin svnadmin-static=svnadmin
+
+_svn () {
+
+ _arguments -s \
+ '*::svn command:_svn_command'
+}
+
+_svnadmin () {
+
+ _arguments -s \
+ '*::svnadmin command:_svnadmin_command'
+}
+
+(( $+functions[_svn_command] )) ||
+_svn_command () {
+ local cmd
+
+ if (( ! $+_svn_cmds )); then
+ typeset -gA _svn_cmds
+ _svn_cmds=(
+ ${=${(f)${${"$(svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
+ )
+ fi
+
+ if (( CURRENT == 1 )); then
+ _tags commands && { compadd "$@" -k _svn_cmds || compadd "$@" ${_svn_cmds} }
+ else
+ local curcontext="$curcontext"
+
+ cmd="${${(k)_svn_cmds[(R)*:$words[1]:*]}:-${(k)_svn_cmds[(i):$words[1]:]}}"
+ if (( $#cmd )); then
+ curcontext="${curcontext%:*:*}:svn-${cmd}:"
+ _svn_subcommand $cmd
+ else
+ _message "unknown svn command: $words[1]"
+ fi
+ fi
+}
+
+(( $+functions[_svn_subcommand] )) ||
+_svn_subcommand () {
+ local subcmd _svn_subcmds _svn_subcmd_usage
+
+ _svn_subcmd_usage=${${(M)${(f)"$(svn help $1)"}:#usage:*}#usage: $1 }
+
+ _svn_subcmds=(
+ ${${=${${${(M)${(f)"$(svn help $1)"##*Valid options:}:#*:*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}[2,-1]}
+ )
+
+ [[ "$_svn_subcmd_usage" == *URL* ]] && _svn_subcmds=($_svn_subcmds ":url:_urls")
+ [[ "$_svn_subcmd_usage" == *PATH* ]] && _svn_subcmds=($_svn_subcmds "*:path:_files")
+
+ _arguments \
+ "$_svn_subcmds[@]" && ret=0
+
+ return ret
+
+}
+
+
+(( $+functions[_svn_admincommand] )) ||
+_svnadmin_command () {
+ local cmd
+
+ if (( ! $+_svnadmin_cmds )); then
+ typeset -gA _svnadmin_cmds
+ _svnadmin_cmds=(
+ ${=${(f)${${"$(svnadmin help)"#l#*Available subcommands:}}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
+ )
+ fi
+
+ if (( CURRENT == 1 )); then
+ _tags commands && { compadd "$@" -k _svnadmin_cmds || compadd "$@" ${(kv)=_svnadmin_cmds} }
+ else
+ local curcontext="$curcontext"
+
+ cmd="${${(k)_svnadmin_cmds[(R)*:$words[1]:*]}:-${(k)_svnadmin_cmds[(i):$words[1]:]}}"
+ if (( $#cmd )); then
+ curcontext="${curcontext%:*:*}:svnadmin-${cmd}:"
+ _svnadmin_subcommand $cmd
+ else
+ _message "unknown svnadmin command: $words[1]"
+ fi
+ fi
+}
+
+(( $+functions[_svnadmin_subcommand] )) ||
+_svnadmin_subcommand () {
+ local subcmd _svnadmin_subcmds _svnadmin_subcmd_usage
+
+ _svnadmin_subcmd_usage=${${(M)${(f)"$(svnadmin help $1)"}:#$1: usage:*}#$1: usage: svnadmin $1 }
+
+ _svnadmin_subcmds=(
+ ${${=${${${(M)${(f)"$(svnadmin help $1)"##*Valid options:}:#*:*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}[2,-1]}
+ )
+
+ [[ "$_svnadmin_subcmd_usage" == *REPOS_PATH* ]] &&
+ _svnadmin_subcmds=($_svnadmin_subcmds ":path:_files -/")
+
+ _arguments \
+ "$_svnadmin_subcmds[@]" && ret=0
+
+ return ret
+
+}
+
+
+_subversion () {
+ case $service in
+ (svn) _svn "$@" ;;
+ (svnadmin) _svnadmin "$@" ;;
+ esac
+}
+
+_subversion "$@"