From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6609 invoked from network); 15 Sep 2008 20:53:21 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 15 Sep 2008 20:53:21 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 48951 invoked from network); 15 Sep 2008 20:52:52 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Sep 2008 20:52:52 -0000 Received: (qmail 14495 invoked by alias); 15 Sep 2008 20:52:45 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25675 Received: (qmail 14484 invoked from network); 15 Sep 2008 20:52:43 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 15 Sep 2008 20:52:43 -0000 Received: from smtprelay02.ispgateway.de (smtprelay02.ispgateway.de [80.67.18.14]) by bifrost.dotsrc.org (Postfix) with ESMTP id F1B4980307AC for ; Mon, 15 Sep 2008 22:52:35 +0200 (CEST) Received: from [212.117.84.15] (helo=fsst.voodoo.lan) by smtprelay02.ispgateway.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1KfL3j-00027s-Gx for zsh-workers@sunsite.dk; Mon, 15 Sep 2008 22:52:35 +0200 Received: from hawk by fsst.voodoo.lan with local (Exim 4.69) (envelope-from ) id 1KfL2g-0004n6-Ri for zsh-workers@sunsite.dk; Mon, 15 Sep 2008 22:51:30 +0200 Date: Mon, 15 Sep 2008 22:51:30 +0200 From: Frank Terbeck To: zsh workers Subject: RFC: _svk completion Message-ID: <20080915205130.GM2182@fsst.voodoo.lan> Mail-Followup-To: zsh workers MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Df-Sender: 430444 X-Virus-Scanned: ClamAV 0.92.1/8250/Mon Sep 15 20:08:28 2008 on bifrost X-Virus-Status: Clean Here it is, a completion for _svk. Very incomplete and not too accurate. It's a start... It completes all commands, handles a few aliases and knows completions for arguments of a handful of commands. Extending it should be fairly simple for people familiar with svk. I'm not a heavy user of svk, but I did this, when I was playing with it. It saved some typing. If there are svk users that want to extend it, here is the code: diff --git a/Completion/Unix/Command/_svk b/Completion/Unix/Command/_svk new file mode 100644 index 0000000..d03646a --- /dev/null +++ b/Completion/Unix/Command/_svk @@ -0,0 +1,191 @@ +#compdef svk + +local comm state tmp +local -a svk_aliases_desc svk_commands svk_main_opts +local -A svk_aliases + +svk_commands=( + 'add:put files and directories under version control' + 'admin:administration tools' + 'annotate:display per-line revision and author info' + 'cat:output the file from depot' + 'checkout:checkout the depotpath' + 'cleanup:remove stalled locks' + 'cmerge:merge specific changes' + 'commit:commit changes to depot' + 'copy:make a versioned copy' + 'delete:remove versioned item' + 'depotmap:create or edit the depot mapping configuration' + 'describe:describe a change' + 'diff:display diff between revisions or checkout copies' + 'help:show help' + 'ignore:ignore files by setting svn:ignore property' + 'import:import directory into depot' + 'info:display information about a file or directory' + 'list:list entries in a directory from depot' + 'log:show log messages for revisions' + 'merge:apply differences between two sources' + 'mirror:initialize a mirrored depotpath' + 'mkdir:create a versioned directory' + 'move:move a file or directory' + 'patch:manage patches' + 'propdel:delete a property on files or dirs' + 'propedit:edit a property on path' + 'propget:display a property on path' + 'proplist:list all properties on files or dirs' + 'propset:set a property on path' + 'pull:bring changes from another repository' + 'push:move changes into another repository' + 'resolved:remove conflict mark from checkout items' + 'revert:revert changes made in checkout copies' + 'smerge:automatically merge all changes between branches' + 'status:display the status of items in the checkout copy' + 'switch:switch to another branch and keep local changes' + 'sync:synchronize a mirrored depotpath' + 'update:bring changes from repository to checkout copies' + 'verify:verify change signatures' +) + +svk_aliases=( + '?' 'help' + 'co' 'checkout' + 'cp' 'copy' + 'depot' 'depotmap' + 'h' 'help' + 'ls' 'list' + 'mi' 'mirror' + 'sy' 'sync' +) + +svk_main_opts=( + '--version[display version information]' + '--help[display help message]' +) + +svk_aliases_desc=() +for tmp in ${(k)svk_aliases} ; do + svk_aliases_desc+=( "${tmp}:alias for ${svk_aliases[$tmp]}" ) +done + +# _svk completion utilities +(( ${+functions[__svk_depots]} )) || +__svk_depots () { + local -a ds + + ds=( + ${${(M)${(f)"$( _call_program depotmap1 svk depotmap --list )"}:#//*}// */} + ${${(M)${(f)"$( _call_program depotmap2 svk mirror --list )"}:#//*}// */} + ) + _describe -t depots 'svk depots' ds +} + +(( ${+functions[__svk_depots_or_path]} )) || +__svk_depots_or_path () { + __svk_depots + _path_files -g '*(/)' +} + +# sub command completions +(( ${+functions[_svk-checkout]} )) || +_svk-checkout () { + _arguments \ + '(--revision -r)'{--revision,-r}'[act on revision REV instead of the head revision]' \ + '(--non-recursive -N)'{--non-recursive,-N}'[do not descend recursively]' \ + '(--list -l)'{--list,-l}'[list checkout paths]' \ + '(--detach -d)'{--detach,-d}'[mark a path as no longer checked out]' \ + '(--quiet -q)'{--quiet,-q}'[quiet mode]' \ + '--export[export mode; checkout a detached copy]' \ + '--floating[create a floating checkout]' \ + '--relocate[relocate the checkout to another path]' \ + '--purge[detach checkout directories which no longer exist]' \ + '*::checkoutarg:__svk_depots_or_path' +} + +(( ${+functions[_svk-copy]} )) || +_svk-copy () { + _arguments \ + '(--revision -r)'{--revision,-r}'[act on revision REV instead of the head revision]' \ + '(--parent -p)'{--parent,-p}'[create intermediate directories as required]' \ + '(--quiet -q)'{--quiet,-q}'[print as little as possible]' \ + '(--message -m)'{--message,-m}'[specify commit message]' \ + '(--file -F)'{--file,-F}'[read commit message from FILENAME]' \ + '(--patch -P)'{--patch,-P}'[instead of commit, save this change as a patch]' \ + '(--sign -S)'{--sign,-S}'[sign this change]' \ + '(--check-only -C)'{--check-only,-C}'[try operation but make no changes]' \ + '--template[use the specified message as the template to edit]' \ + '--encoding[treat -m/-F value as being in charset specified encoding]' \ + '--direct[commit directly even if the path is mirrored]' \ + '*::copyarg:__svk_depots' +} + +(( ${+functions[_svk-depotmap]} )) || +_svk-depotmap () { + _arguments \ + '(--init -i)'{--init,-i}'[initialize a default depot]' \ + '(--list -l)'{--list,-l}'[list current depot mappings]' \ + '(--detach -d)'{--detach,-d}'[remove a depot from the mapping]' \ + '--relocate[relocate the depot to another path]' \ + '*::depmaparg:__svk_depots_or_path' +} + +(( ${+functions[_svk-help]} )) || +_svk-help () { + local -a help_subjects + help_subjects=( + 'commands:a list of all available commands' + 'environment:environment variables that alter svk'\''s behavior' + 'intro:a little introductory speech' + 'view:svk view support' + ) + _describe -t subjects 'svk help subjects' help_subjects + _describe -t commands 'svk command help' svk_commands +} + +(( ${+functions[_svk-mirror]} )) || +_svk-mirror () { + _arguments \ + '(--list -l)'{--list,-l}'[list mirrored paths]' \ + '(--detach -d)'{--detach,-d}'[mark a depotpath as no longer mirrored]' \ + '--relocate[change the upstream URI for the mirrored depotpath]' \ + '--recover[recover the state of a mirror path]' \ + '--unlock[forcibly remove stalled locks on a mirror]' \ + '--upgrade[upgrade mirror state to the latest version]' \ + '*::mirrorarg:__svk_depots_or_path' +} + +(( ${+functions[_svk-sync]} )) || +_svk-sync () { + _arguments \ + '(--all -a)'{--all,-a}'[synchronize all mirrored paths]' \ + '(--skipto -s)'{--skipto,-s}'[start synchronization at revision REV]:' \ + '(--torev -t)'{--,-}'[stop synchronization at revision REV]:' \ + '*::syncarg:__svk_depots' +} + +# main commands completion +(( ${+functions[_svk-commands]} )) || +_svk-commands () { + _describe -t commands 'svk commands' svk_commands + _describe -t aliases 'svk aliases' svk_aliases_desc +} + +# _svk() +_arguments -C \ + ${svk_main_opts} \ + '*::arg:->cmd_or_options' && return + +case ${state} in +(cmd_or_options) + if (( CURRENT == 1 )); then + _svk-commands + else + if [[ -n ${svk_aliases[$words[1]]} ]] ; then + comm=${svk_aliases[$words[1]]} + else + comm=${words[1]} + fi + curcontext="${curcontext%:*:*}:svk-${comm}:" + (( ${+functions[_svk-${comm}]} )) && _svk-${comm} + fi + ;; +esac