From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1209 invoked from network); 31 May 2005 07:21:31 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 May 2005 07:21:31 -0000 Received: (qmail 37606 invoked from network); 31 May 2005 07:21:25 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 May 2005 07:21:25 -0000 Received: (qmail 10627 invoked by alias); 31 May 2005 07:21:22 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21293 Received: (qmail 10617 invoked from network); 31 May 2005 07:21:20 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 31 May 2005 07:21:20 -0000 Received: (qmail 37287 invoked from network); 31 May 2005 07:21:20 -0000 Received: from grunt23.ihug.com.au (203.109.249.143) by a.mx.sunsite.dk with SMTP; 31 May 2005 07:21:15 -0000 Received: from (localhost.localdomain) [202.59.110.195] by grunt23.ihug.com.au with esmtp (Exim 3.35 #1 (Debian)) id 1Dd13g-0003Ss-00; Tue, 31 May 2005 17:21:05 +1000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.12.8/8.12.8) with ESMTP id j4V7GXrI010567 for ; Tue, 31 May 2005 17:16:34 +1000 Received: (from doug@localhost) by localhost.localdomain (8.12.8/8.12.8/Submit) id j4V7Fswj010559 for zsh-workers@sunsite.dk; Tue, 31 May 2005 17:15:54 +1000 X-Authentication-Warning: localhost.localdomain: doug set sender to dougkearns@gmail.com using -f Date: Tue, 31 May 2005 17:15:53 +1000 From: Doug Kearns To: zsh-workers@sunsite.dk Subject: PATCH: ant completion update Message-ID: <20050531071553.GC4435@localhost.localdomain> Mail-Followup-To: zsh-workers@sunsite.dk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 This is an update for version 1.6.4 of ant. 'call-command' style completion of targets should now work with build files specified via the -find or -buildfile options. Regards, Doug Index: Completion/Unix/Command/_ant =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ant,v retrieving revision 1.10 diff -u -r1.10 _ant --- Completion/Unix/Command/_ant 25 Feb 2005 14:09:28 -0000 1.10 +++ Completion/Unix/Command/_ant 31 May 2005 07:02:20 -0000 @@ -1,11 +1,10 @@ #compdef ant -value-,ANT_ARGS,-default- -typeset -A opt_args -local buildfile tmp state line curcontext="$curcontext" ret=1 -local targets importedfiles -local c target='*:target:->target' +# Apache Ant version 1.6.4 -c=( $ANT_HOME/lib/*.jar ) +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args +local buildfile classpath cp userjars importedfiles target='*:target:->target' targets tmp if [[ $service = *ANT_ARGS* ]]; then compset -q @@ -15,86 +14,111 @@ fi _arguments -C \ - '-help[display usage information]' \ - '-projecthelp[print project help information]' \ - '-version[display version information]' \ - '-diagnostics[display info useful to problem diagnosis]' \ + '(- *)'{-h,-help}'[display help information]' \ + '(-p -projecthelp *)'{-p,-projecthelp}'[print project help information]' \ + '(- *)-version[display version information]' \ + '(- *)-diagnostics[print information helpful to diagnosis or report problems]' \ '(-q -quiet)'{-q,-quiet}'[be extra quiet]' \ - '(-v -verbose)'{-v,-verbose}'[be more verbose]' \ - '-debug[print debugging information]' \ - '-emacs[produce logging information without adornments]' \ + '(-v -verbose)'{-v,-verbose}'[be extra verbose]' \ + '(-d -debug)'{-d,-debug}'[print debugging information]' \ + '(-e -emacs)'{-e,-emacs}'[produce logging information without adornments]' \ + '*-lib[specify a path to search for jars and classes]:class path:->classpath' \ '(-l -logfile)'{-l,-logfile}'[use specified file for log]:logfile:_files' \ - '-logger[the class which is to perform logging]:classname:_java_class -cp ${(j.:.)c}' \ - '*-listener[add an instance of class as a project listener]:classname:_java_class -cp ${(j.:.)c}' \ - '(-f -file -buildfile -find)'{-f,-file,-buildfile}'[use specified build file]:build file:_files' \ + '-logger[specify the class which is to perform logging]:class:->class' \ + '*-listener[add an instance of specified class as a project listener]:class:->class' \ + '-noinput[do not allow interactive input]' \ + '(-f -file -buildfile -s -find)'{-f,-file,-buildfile}'[use specified build file]:build file:_files -g "*.xml(-.)"' \ '*-D[specify property with value to use]:property:->property' \ - '-propertyfile[load properties from specified file]:property file:_files' \ - '-inputhandler[specify class which will handle input requests]:class:_java_class -cp ${(j.\:.)c}' \ - '(-f -file -buildfile)-find[search for build file towards the root of filesystem]:build file:(build.xml)' \ + '(-k -keep-going)'{-keep-going,-k}'[execute all targets that do not depend on failed target(s)]' \ + '-propertyfile[load all properties from specified file with -D properties taking precedence]:property file:_files -g "*.properties(-.)"' \ + '-inputhandler[specify class which will handle input requests]:class:->class' \ + '(-s -find -f -file -buildfile)'{-s,-find}'[search for specified build file towards the root of filesystem]:build file:(build.xml)' \ + '-nice[specify a niceness value for the main thread]:niceness value (default 5):({1..10})' \ + '-nouserlib[run ant without using the jar files from ${user.home}/.ant/lib]' \ + '-noclasspath[run ant without using CLASSPATH]' \ $target && ret=0 case $state in + class) + if (( ! $+opt_args[-nouserlib] )); then + userjars=( $HOME/.ant/lib/*.jar ) + fi + if (( ! $+opt_args[-noclasspath] )); then + classpath=$CLASSPATH + fi + cp=( $opt_args[-lib] $userjars $ANT_HOME/lib/*.jar $classpath ) + cp=${(j.:.)cp:-' '} + _java_class -classpath $cp && ret=0 + ;; + classpath) + compset -P '*:' + compset -S ':*' + _alternative \ + "classpath:$state:_path_files -qS: -g '*.(jar|zip)(-.)'" \ + "classpath:$state:_path_files -r': ' -/" && ret=0 + ;; property) if compset -P '*='; then - _default + _default && ret=0 else _message -e properties 'property name' fi ;; target) - if zstyle -t ":completion:${curcontext}:targets" call-command; then - # Run ant -projecthelp also passing any of -find, -buildfile or -f options. - # Parse output into an array of the format "target:description". - # For the array to be set with correct argument boundaries, the entire - # set statement needs to be eval'd. On Cygwin, need to kill \r's output - # from Java or parsing will fail. - eval set -A tmp "${$(_call_program targets "$words[1]" $buildxml -projecthelp | - while read target desc - do - # This loop reads ant -projecthelp output from versions 1.3 to 1.5 - ln="${target}${desc:+:$desc}" - [[ $target = "" ]] && continue # skip blank lines - case $ln in - (Buildfile:*) - buildfile=$desc - ;; - (Default:target:*) - # with version 1.5, target is on the same line - default_target="${${desc/target:/}# }" - # versions 1.3 and 1.4 with default target on a separate line - if [[ -z $default_target ]]; then - read junk - read default_target junk - fi - # Output target again indicating its the default one. - print -n "'${default_target}:(Default target) ' " - ;; - (Searching:*|Main:targets:|Subtargets:|BUILD:SUCCESSFUL|Total:time: - *) - ;; - (*) - # Return target and description - print -n "'$ln' " - ;; - esac - done - )//$'\015'}" - _describe 'target' tmp && ret=0 + if [[ -n $opt_args[(I)(-s|-find)] ]]; then + buildfile=( (../)#${(v)opt_args[(I)(-s|-find)]:-build.xml}(N[-1]) ) else - if [[ -n $opt_args[-find] ]]; then - buildfile=( (../)#${opt_args[-find]:-build.xml}(N[-1]) ) + buildfile=${(v)opt_args[(I)(-f|-file|-buildfile)]:-build.xml} + fi + if [[ -f $buildfile ]]; then + if zstyle -t ":completion:${curcontext}:targets" call-command; then + # Run ant -projecthelp also passing any of -find, -s, -buildfile, -file + # or -f options. + # Parse output into an array of the format "target:description". + # For the array to be set with correct argument boundaries, the entire + # set statement needs to be eval'd. On Cygwin, need to kill \r's output + # from Java or parsing will fail. + eval set -A tmp "${$(_call_program targets "$words[1]" -buildfile $buildfile -projecthelp | + while read target desc + do + # This loop reads ant -projecthelp output from versions 1.3 to 1.6 + ln="${target}${desc:+:$desc}" + [[ $target = "" ]] && continue # skip blank lines + case $ln in + (Buildfile:*) + buildfile=$desc + ;; + (Default:target:*) + # with version 1.5, target is on the same line + default_target="${${desc/target:/}# }" + # versions 1.3 and 1.4 with default target on a separate line + if [[ -z $default_target ]]; then + read junk + read default_target junk + fi + # Output target again indicating its the default one. + print -n "'${default_target}:(Default target) ' " + ;; + (Searching:*|Main:targets:|Subtargets:|BUILD:SUCCESSFUL|Total:time: + *) + ;; + (*) + # Return target and description + print -n "'$ln' " + ;; + esac + done + )//$'\015'}" + _describe 'target' tmp && ret=0 else - buildfile=${(v)opt_args[(I)(-f|-file|-buildfile)]:-build.xml} - fi - if [[ -f $buildfile ]]; then importedfiles=( $(sed -n "s/ *]* file=[\"']\([^\"']*\)[\"'].*/\1/p" < $buildfile) ) targets=( $(sed -n "s/ *]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $buildfile) ) (( $#importedfiles )) && targets+=( $(cd $buildfile:h; - sed -n "s/ *]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $importedfiles) ) - _wanted targets expl target compadd -a targets && ret=0 - else - _message -e targets target + sed -n "s/ *]* name=[\"']\([^\"']*\)[\"'].*/\1/p" $importedfiles) ) + _wanted targets expl target compadd -a targets && ret=0 fi + else + _message -e targets target fi ;; esac