blob: 81188b25df8e02fe956fcff51935a843dc9d992b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
#compdef svn svnadmin svnadmin-static=svnadmin
_svn () {
_arguments -s \
'(-)--help[print help information]' \
'(- *)--version[print client version information]' \
'*::svn command:_svn_command'
}
_svnadmin () {
_arguments -s \
'(-)--help[print help information]' \
'(- *)--version[print client version information]' \
'*::svnadmin command:_svnadmin_command'
}
(( $+functions[_svn_controlled] )) ||
_svn_controlled() {
[[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]]
}
(( $+functions[_svn_urls] )) ||
_svn_urls() {
local expl
if [[ -prefix *: ]]; then
_urls
else
compset -S '[^:]*'
_wanted url-schemas expl 'URL schema' compadd -S '' - \
file:// http:// https:// svn:// svn+ssh://
fi
}
(( $+functions[_svn_command] )) ||
_svn_command () {
local cmd
if (( ! $+_svn_cmds )); then
typeset -gA _svn_cmds
_svn_cmds=(
${=${(f)${${"$(LC_MESSAGES=C _call_program commands 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 "$@" ${(s.:.)_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)"$(LC_MESSAGES=C _call_program options svn help $1)"}:#usage:*}#usage: $1 }
_svn_subcmds=(
${${=${${${(M)${(f)"$(LC_MESSAGES=C _call_program options 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]}
)
case $1 in;
add)
_svn_subcmds+=(
'*:file:_files -g "*(^e:_svn_controlled:)"'
)
;;
log)
_svn_subcmds+=(
'1: : _alternative "files:file:_files -g \*\(e:_svn_controlled:\)" "urls:URL:_svn_urls"'
'*:file:_files -g "*(e:_svn_controlled:)"'
)
;;
*)
case $_svn_subcmd_usage in
*(SRC|DST|TARGET|URL*PATH)*)
_svn_subcmds+=(
'*: : _alternative "files:file:_files" "urls:URL:_svn_urls"'
)
;;
*URL*) _svn_subcmds+=( ':URL:_svn_urls' ) ;;
*PATH*) _svn_subcmds+=( '*:file:_files' ) ;;
esac
;;
esac
_arguments "$_svn_subcmds[@]" && ret=0
return ret
}
(( $+functions[_svnadmin_command] )) ||
_svnadmin_command () {
local cmd
if (( ! $+_svnadmin_cmds )); then
typeset -gA _svnadmin_cmds
_svnadmin_cmds=(
${=${(f)${${"$(LC_MESSAGES=C _call_program commands 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 "$@" ${(s.:.)_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)"$(LC_MESSAGES=C _call_program options svnadmin help $1)"}:#$1: usage:*}#$1: usage: svnadmin $1 }
_svnadmin_subcmds=(
${${=${${${(M)${(f)"$(LC_MESSAGES=C _call_program options 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 "$@"
|