From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26874 invoked by alias); 30 Mar 2018 14:06:47 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42567 Received: (qmail 27582 invoked by uid 1010); 30 Mar 2018 14:06:47 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(205.235.26.22):SA:0(0.2/5.0):. Processed in 1.155005 secs); 30 Mar 2018 14:06:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID,T_RP_MATCHES_RCVD autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=g5DA=GU=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1522418799; bh=seSA/jhg7UAJD1CljvCE2h5ve/SdZwQIcSxbON2o84A=; h=From:To:Subject:Date:From:Subject; b=LmCw1ZF8o9GoH+x2CogVucka1brgT9x5t3amQl4lp+bj0claR6yNKu6xNZ1FN6XnJyWUfF3xQLh9Azxt6ZsHzQNChMBTbcWxOJzR9Er4R3myJl+ehXYYGTdsCgkNpVCQGja9Fiu/amuMtNf42NFzIi0uLovI5UtkDxlEPwiroq0IBeAkIawTiYP1yq/JE3YfJYsNqXI8EEtFms94kYPVnblf7JqSEOo5vbTc3wSMPoolozd2FPMLpFHeEDPNqGq8h3QfE6YBQ0bHYLjtwDkSr8MjR/G/6WcGziwdg8eCPHQfcVYfI/HckODVXGywgS0gnArJedykhfqtIHBNWAysBA== X-YMail-OSG: NRdJz.gVM1mDoHs6cGlId6GbLpFf.W5M8vz0C8MJAVTJdxJzrO.VKHibR4HkyME GSGElTqRq.1.67XkldzPvA2nlk1quQ5ZoaQm1Hsd3faH5soIltI70F6WfhhRbEKXOpUvXOeaTJ86 JWei07HNI.iq42ok38ldIJCMSQDBqWGUy7C.tNUK0SkKFBVRAe5hlfSC8cZ2bxO0l6XgbkBRfi9W 86PATwncfV5AE6_XuYNe9khe8Ap29WfM3pUIJEuf8mZ2Dzy6OVygNbrntFn0VCB5FrmE_9qPW8IN RAeXfW1YwbHby2KHZoASFlnwGZNM4ssSyUihTfPApmUpRT_atXkw32A4hlV_UIbPNM9ic2Uo9nke dGvpKvTMpg46JnrVm5tJ0.5L1_cS.BN5QSuwHkQq4f4OaCbAI5moBjPscbJw1ywKxjdyTe2tCCaf gdZttrI.zI76Cim64LtRayLpFkKSh3P4BuA2j_jDie34TvjMYcT.m2l3A3QbEN9cDzToPh.IPUi0 quaspnZP85A-- From: Oliver Kiddle To: Zsh workers Subject: PATCH: xmlstarlet completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17768.1522404266.1@thecus> Date: Fri, 30 Mar 2018 12:04:26 +0200 Message-ID: <17769.1522404266@thecus> This is a new completion for xmlstarlet. I've had most of this sitting around unfinished for many years so it isn't really new. Oliver diff --git a/Completion/Unix/Command/_xmlstarlet b/Completion/Unix/Command/_xmlstarlet new file mode 100644 index 000000000..4c8257046 --- /dev/null +++ b/Completion/Unix/Command/_xmlstarlet @@ -0,0 +1,177 @@ +#compdef xmlstarlet xml + +local curcontext="$curcontext" ret=1 +local -a args state line suf + +args=( '(- *)--help[display usage information]' ) +_arguments -C -A "-*" $args \ + '(-q --quiet)'{-q,--quiet}'[no error output]' \ + "--no-doc-namespace[don't extract namespace bindings from input doc]" \ + '!(--no-doc-namespace)--doc-namespace' \ + '(-)--version[display version information]' \ + '1:command:(( + ed{,it}\:edit\ or\ update\ documents + sel{,ect}\:select\ date\ or\ query\ documents + tr{,ransform}\:transform\ documents\ using\ XSLT + val{,idate}\:validate\ documents + fo{,rmat}\:format\ documents + el{,ements}\:display\ element\ structure + {c14n,canonic}\:XML\ canonicalization + l{s,ist}\:list\ directory\ as\ XML + esc{,ape}\:escape\ special\ XML\ characters + unesc{,ape}\:unescape\ special\ XML\ characters + {pyx,xmln}\:convert\ XML\ into\ the\ line-oriented\ PYX\ format + {p2x,depyx}\:convert\ PYX\ into\ XML + ))' \ + '*: :->args' && ret=0 + +if [[ -n $state ]]; then + shift words + (( CURRENT-- )) + curcontext="${curcontext%:*:*}:$service-${words[1]}:" + case $words[1] in + el(|ements)|fo(|rmat)|sel(|ect)|c14n|canonic|xmln|pyx) + args+=( '1:file:_files -g "(#i)*.xml(-.)"' ) + ;| + ed(|it)|sel(|ect)) + args+=( '*-N[predefine namespaces]:namespace' ) + ;| + c14n|canonic|ed(|it)|fo(|rmat)|sel(|ect)|tr(|ansform)|val(|idate)) + args+=( '--net[allow fetching of DTDs or entities over network]' ) + ;| + fo(|rmat)|tr(|ansform)) + args+=( '(-o --omit-decl)'{-o,--omit-decl}'[omit XML declaration]' ) + ;| + + ed(|it)) + args=( + '(opt)*'{-d,--delete}'[remove element]:xpath expression' + '(opt)*'{-i,--insert}'[add element before node matched by expression]:xpath expression - insert before matched node' + '(opt)*'{-a,--append}'[add element after node matched by expression]:xpath expression - insert after matched node' + '(opt)*'{-s,--subnode}'[add element as a child of node matched by expression]:xpath expression for parent modes' + '(opt)*'{-m,--move}'[move element]:xpath expression: :xpath expression' + '(opt)*'{-r,--rename}'[rename element]:xpath expression' + '(opt)*'{-u,--update}'[update element]:xpath expression' + '*:file:_files -g "(#i)*.xml(-.)"' + + opt $args + '(-P -S --pf --ps)'{-P,-S,--pf,--ps}'[preserve whitespace nodes]' + '(-O --omit-decl)'{-O,--omit-decl}'[omit XML declaration]' + '(-L --inplace)'{-L,--inplace}'[edit file inplace]' + ) + if [[ -n ${${words[2,CURRENT-1]}[(r)-([ias]|-insert|-append|-subnode)]} ]]; then + args=( + '(opt)*'{-t,--type}'[specify type of node to add]:type:(elem text attr)' + '(opt)*'{-n,--name}'[specify name of node to add]:name' + $args + ) + fi + if [[ -n ${${words[2,CURRENT-1]}[(r)-([iasru]|-insert|-append|-subnode|-rename|-update)]} ]]; then + args=( '(opt)*'{-v,--value}'[specify value of node to add or name of renamed node]:value' $args ) + fi + ;; + el(|ements)) + args+=( + '(-)-a[show attributes as well]' + '(-)-v[show attributes and their values]' + '(-)-u[print out sorted unique lines]' + '(-)-d-[print out sorted unique lines up to specified depth]:depth' + ) + ;; + fo(|rmat)) + args+=( + '(-t --indent-tab -s --indent-spaces -n --noindent)'{-n,--noindent}"[don't indent]" + '(-t --indent-tab -s --indent-spaces -n --noindent)'{-t,--indent-tab}'[indent output with tabs]' + '(-t --indent-tab -s --indent-spaces -n --noindent)'{-s,--indent-spaces}'[indent output with specified number of spaces]:spaces' + '(-R --recover)'{-R,--recover}'[try to recover what is parsable]' + '(-D --dropdtd)'{-D,--dropdtd}'[remove the DOCTYPE of the input docs]' + '(-C --nocdata)'{-C,--nocdata}'[replace cdata section with text nodes]' + '(-N --nsclean)'{-N,--nsclean}'[remove redundant namespace declarations]' + '(-e --encode)'{-e,--encode}'[output in the specified encoding]:encoding' + '(-H --html)'{-H,--html}'[input is HTML]' + ) + ;; + sel(|ect)) + [[ -n ${${words[2,CURRENT-1]}[(r)-t]} ]] && args+=( + \*{-c,--copy-of}'[print copy of XPath expression]:xpath expression' + \*{-v,--value-of}'[print value of XPath expression]:xpath expression' + \*{-o,--output}'[output string literal]:string' + \*{-n,--nl}'[print new line]' + \*{-f,--inp-name}'[print input file name (or URL)]' + \*{-m,--match}'[match XPath expression]:xpath expression' + \*{-v,--var}'[declare a variable]:variable' + \*{-i,--if,--elif}'[check condition]:condition' + '*--else[check if previous conditions failed]' + \*{-e,--elem}'[print out specified element]:element' + \*{-b,--break}'[break nesting]' + \*{-s,--sort}'[specify sort order]:order:->ordering:xpath expression' + ) + args+=( + '(opt)*-t[start query template]' + + opt + '(-Q --quiet)'{-Q,--quiet}"[don't write anything to standard output]" + '(-C --comp)'{-C,--comp}'[display generated XSLT]' + '(-R --root)'{-R,--root}'[print root element]' + '(-T --text -e --elem)'{-T,--text}'[output is text]' + '(-I --indent)'{-I,--indent}'[indent output]' + '(-D --xml-decl)'{-D,--xml-decl}"[don't omit xml declaration line]" + '(-B --noblanks)'{-B,--noblanks}'[remove insignificant spaces from XML tree]' + '(-E --encode)'{-E,--encode}'[output in the specified encoding]:encoding' + ) + ;; + tr(|ansform)) + args+=( + '(--embed -E)'{--embed,-E}'[allow applying embedded stylesheet]' + '(1 * -)--show-ext[show list of extensions]' + '--val[allow validation against DTD or schema]' + '--xinclude[do XInclude processing on document input]' + '--maxdepth[increase the maximum depth]:val' + '--html[input is HTML]' + '1:xsl file:_files -g "(#i)*.xsl(|t)(-.)"' + '*:xml file:_files' + ) + ;; + val(|idate)) + args+=( + '!(-d --dtd -s --xsd -r --relaxng)'{-w,--well-formed} + '(-d --dtd -s --xsd -r --relaxng)'{-d,--dtd}'[validate against DTD]:file:_files -g "(#i)*.dtd(-.)"' + '(-d --dtd -s --xsd -r --relaxng)'{-s,--xsd}'[validate against XSD schema]:schema file:_files -g "(#i)*.xsd(-.)"' + '(-E --embed)'{-E,--embed}'[validate using embedded DTD]' + '(-d --dtd -s --xsd -r --relaxng)'{-r,--relaxng}'[validate against schema]:schema file:_files -g "(#i)*.rng(-.)"' + '(-e --err)'{-e,--err}'[print verbose error messages on stderr]' + '(-S --stop)'{-S,--stop}'[stop on first error]' + '(-b --list-bad -g --list-good)'{-b,--list-bad}"[list only files that don't validate]" + '(-b --list-bad -g --list-good -q --quiet)'{-g,--list-good}'[list only files that validate]' + '(-b --list-bad -g --list-good -q --quiet)'{-q,--quiet}"[don't list files (return result code only)]" + '*:file:_files -g "(#i)*.xml(-.)"' + ) + ;; + c14n|canonic) + args+=( + '!(-)--with-comments' + '(-)--without-comments[XML file canonicalization without comments]' + '(-)--exc-with-comments[exclusive XML file canonicalization with comments]' + '(-)--exc-without-comments[exclusive XML file canonicalization without comments]' + '2:xpath file:_files' + '3:namespace prefix list' + ) + ;; + (un|)esc(|ape)) args+=( '1: :_guard "^-*" string' ) ;; + ls|list) args+=( '1:path:_directories' ) ;; + depyx|p2x) args+=( '1:pyx file:_files' ) ;; + esac + _arguments -C -A "-*" $args && ret=0 + case $state in + ordering) + compset -S ':*' || suf=( -S : ) + if compset -P 2 '*:'; then + _describe -t case-order case-order '(U:upper-first L:lower-first)' && ret=0 + elif compset -P 1 '*:'; then + _describe -t data-type data-type '(N:numeric T:text)' $suf && ret=0 + else + _describe -t order order '(A:ascending D:descending)' $suf && ret=0 + fi + ;; + esac +fi + +return ret