* PATCH: subversion completion should allow --config-option more than once
@ 2018-02-06 23:51 Oliver Kiddle
0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2018-02-06 23:51 UTC (permalink / raw)
To: Zsh workers
With svn, --config-option can be specified multiple times so needs *
adding the _arguments spec. The patch also adds a function for
completing at least the first couple of components of the argument to
--config-option. I'm not sure why the args handling code repeats the
subscript searches when it has saved the index in idx. Have I missed
something in changing that? I've also made the function complete for
svnlite which is the name given to the minimal svn client in FreeBSD
base.
Oliver
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
index 6a35e9947..be1f42f85 100644
--- a/Completion/Unix/Command/_subversion
+++ b/Completion/Unix/Command/_subversion
@@ -1,4 +1,4 @@
-#compdef svn svnadmin svnadmin-static=svnadmin
+#compdef svn svnlite=svn svnadmin svnadmin-static=svnadmin
_svn () {
local curcontext="$curcontext" state line expl ret=1
@@ -24,7 +24,7 @@ _svn () {
zstyle ":completion:*:*:$service:*" cache-policy _svn_caching_policy
fi
- _arguments -C \
+ _arguments -C -A "-*" \
'(-)--help[print help information]' \
'(- *)--version[print client version information]' \
'1: :->cmds' \
@@ -70,29 +70,32 @@ _svn () {
${=${${${(M)${(f)"$(_call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) \[--([a-z-]##)\](:arg:)#/(--$match[3])$match[1]$match[2]$match[4] ($match[1]$match[2])--$match[3]$match[4]}
)
while (( idx=$args[(I)*--accept:arg:] )); do
- args[(I)*--accept:arg:]=( --accept'=:automatic conflict resolution action:((working\:working base\:base '"`for i j in p postpone mc mine-conflict tc theirs-conflict mf mine-full tf theirs-full e edit l launch; do print -rn $i\\\\:$j $j\\\\:$j ""; done `"'))' )
+ args[idx]=( --accept'=:automatic conflict resolution action:((working\:working base\:base '"`for i j in p postpone mc mine-conflict tc theirs-conflict mf mine-full tf theirs-full e edit l launch; do print -rn $i\\\\:$j $j\\\\:$j ""; done `"'))' )
done
while (( idx=$args[(I)*--c(l|hangelist):arg:] )); do
- args[(I)*--c(l|hangelist):arg:]=( \*{--cl,--changelist}'=:change list:_svn_changelists' )
+ args[idx]=( \*{--cl,--changelist}'=:change list:_svn_changelists' )
done
while (( idx=$args[(I)*--config-dir:arg:] )); do
- args[(I)*--config-dir:arg:]=( --config-dir'=:config dir:_directories' )
+ args[idx]=( --config-dir'=:config dir:_directories' )
done
+ while (( idx=$args[(I)*--config-option:arg:] )); do
+ args[idx]=( '*--config-option=: :_svn_config_options' )
+ done
while (( idx=$args[(I)*--depth:arg:] )); do
- args[(I)*--depth:arg:]=( --depth'=:operation depth (how far to recurse):(empty files immediates infinity)' )
+ args[idx]=( --depth'=:operation depth (how far to recurse):(empty files immediates infinity)' )
done
while (( idx=$args[(I)*(-F|--file):arg:] )); do
- args[(I)*(-F|--file):arg:]=( '(-F --file)'{-F+,--file=}':log message file:_files' )
+ args[idx]=( '(-F --file)'{-F+,--file=}':log message file:_files' )
done
while (( idx=$args[(I)*--set-depth:arg:] )); do
- args[(I)*--set-depth:arg:]=( --set-depth'=[make working copy deeper or shallower]:new depth:(exclude empty files immediates infinity)' )
+ args[idx]=( --set-depth'=[make working copy deeper or shallower]:new depth:(exclude empty files immediates infinity)' )
done
while (( idx=$args[(I)*--trust-server-cert-failures:arg:] )); do
- args[(I)*--trust-server-cert-failures:arg:]=( --trust-server-cert-failures'=:failures:_values -s , "certificate failures to ignore" "unknown-ca[unknown authority]" "cn-mismatch[hostname mismatch]" "expired[certificate expired]" "not-yet-valid[certificate not yet valid]" "other[all other failures]"' )
+ args[idx]=( --trust-server-cert-failures'=:failures:_values -s , "certificate failures to ignore" "unknown-ca[unknown authority]" "cn-mismatch[hostname mismatch]" "expired[certificate expired]" "not-yet-valid[certificate not yet valid]" "other[all other failures]"' )
done
while (( idx=$args[(I)*--show-item:arg:] )); do
# (q) to quote the parentheses in the value
- args[(I)*--show-item:arg:]=( --show-item'=:item key:(('"`for i j in ${(kv)show_item_keys}; do print -rn - $i\\\\:"${(q)j}" ""; done`"'))' )
+ args[idx]=( --show-item'=:item key:(('"`for i j in ${(kv)show_item_keys}; do print -rn - $i\\\\:"${(q)j}" ""; done`"'))' )
done
# All other options get {-x+,--long-x=}
args=( ${args/(#b)(--[A-Za-z0-9-]##):arg:/$match[1]=:arg:} )
@@ -417,6 +420,27 @@ _svnadmin_commands() {
compadd "$@" -k _svnadmin_cmds || compadd "$@" ${(s.:.)_svnadmin_cmds}
}
+(( $+functions[_svn_config_options] )) ||
+_svn_config_options() {
+ local -a expl suf
+ local cfgfile
+ compset -S ':*' || suf=( -qS : )
+ if compset -P 2 '*:'; then
+ if compset -P '*='; then
+ _message -e values 'value'
+ else
+ _message -e options 'option'
+ fi
+ elif compset -P 1 '*:'; then
+ cfgfile=( ~/.subversion/${(M)${IPREFIX%:}%(config|servers)}(N) /dev/null )
+ _description sections expl 'section'
+ compadd $suf "$expl[@]" ${${${(M)${(f)"$(<${cfgfile[1]})"}:#\[*\]}#\[}%\]}
+ else
+ _description config-files expl 'configuration file'
+ compadd $suf "$expl[@]" config servers
+ fi
+}
+
(( $+functions[_svn_props] )) ||
_svn_props() {
local properties
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-02-07 0:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-06 23:51 PATCH: subversion completion should allow --config-option more than once Oliver Kiddle
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).