zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _xargs: add many options
@ 2010-03-22  3:38 Benjamin R. Haskell
  2010-03-22 10:40 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin R. Haskell @ 2010-03-22  3:38 UTC (permalink / raw)
  To: Zsh Workers

This is a first pass at adding a lot of options that aren't present in 
xargs completion.  Two questions, after which I'll rework this.

1. I suspect a lot of these are GNU-specific.  Can someone point me to a 
good example of the use of _variant (sp?) for another command that has 
both GNU- and non-GNU completion?

2. The old parameters passed to _arguments were mainly of the form:

   '(-mutually_exclusive)-option:some help text:' \

I changed it so that the help text shows up...

   '(-mutually_exclusive)-option[some help text]::' \

but maybe I'm doing something wrong?  What's the expected difference in 
behavior between an optspec of:

-optname[explanation]::

vs.

-optname:message:

?

Best,
Ben

---
 Completion/Unix/Command/_xargs |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/Completion/Unix/Command/_xargs b/Completion/Unix/Command/_xargs
index f727ed8..905aaba 100644
--- a/Completion/Unix/Command/_xargs
+++ b/Completion/Unix/Command/_xargs
@@ -1,15 +1,19 @@
 #compdef xargs
 
 _arguments \
-  '(-t)-p[prompt user for each command]' \
-  '(-p)-t[verbose - echo each command]' \
-  '-x[exit if max size exceeded]' \
-  -{e-,E}':end-of-file string:' \
-  '(-x -I)-i-:replacement string for lines:' \
-  '(-x -i)-I:replacement string for lines:' \
-  '(-n -L -x)-l-:number of input lines:' \
-  '(-n -l)-L:number of input lines:' \
-  '(-l -L)-n-:maximum number of arguments:' \
-  '-s-:maximum command line length:' \
+  '(-t --verbose)'{-p,--interactive}'[prompt user for each command]' \
+  '(-p --interactive)'{-t,--verbose}'[verbose - echo each command]' \
+  {-x,--exit}'[exit if max size exceeded]' \
+  -{e-,E,-eof}'[end-of-file string]::' \
+  '(-x -I)-i-[replacement string for lines]::' \
+  '(-x -i)-I[replacement string for lines]::' \
+  '(-n -L -x)-l-[number of input lines]::' \
+  '(-n -l)-L[number of input lines]::' \
+  '(-l -L)'{-n-,--max-args}'[maximum number of arguments]::' \
+  {-s-,--max-chars}'[maximum command line length]::' \
+  {-P-,--max-procs}'[maximum simultaneous processes]::' \
+  '(-0 --null)'{-d-,--delimiter}'[terminate input items on the specified delimiter]::' \
+  '(-d --delimiter)'{-0,--null}'[terminate input items on a null character]::' \
+  {-r,--no-run-if-empty}'[do not run if there are no items]' \
   '(-):command: _command_names -e' \
   '*::args: _normal'
-- 
1.7.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] _xargs: add many options
  2010-03-22  3:38 [PATCH] _xargs: add many options Benjamin R. Haskell
@ 2010-03-22 10:40 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2010-03-22 10:40 UTC (permalink / raw)
  To: Zsh Workers

On Sun, 21 Mar 2010 23:38:58 -0400 (EDT)
"Benjamin R. Haskell" <zsh@benizi.com> wrote:
> 1. I suspect a lot of these are GNU-specific.  Can someone point me to a 
> good example of the use of _variant (sp?) for another command that has 
> both GNU- and non-GNU completion?

They're scattered through Completion/Unix/Command.  None of them are
particularly canonical, but the form "_pick_variant gnu=GNU unix --version"
is fairly common.  Searching for some component of "Free Software
Foundation" in the --version or --help output is also common, however since
xargs --version gives something like

GNU xargs version 4.2.31
Built using GNU gnulib version 2007-02-24

and --help doesn't give anything very useful, I think you need something
like the first form.

The only thing to be wary of in _pick_variant is if "<cmd> --version" might
be interpreted as "rm -rf /" or something else nasty if --version isn't
understood.  That's not a worry for xargs.

> What's the expected difference in behavior between an optspec of:
> 
> -optname[explanation]::
> 
> vs.
> 
> -optname:message:
> 
> ?

This is in the manual: the former documents the option itself, the second
documents its argument.  If the option has an argument the second form
should be present since otherwise you get no information about the argument
(from _arguments, anyway, if the completion defined in the arguments to
_arguments descends to another fully implemented completer instead of
e.g. specifying an array of possible values you may get information from
down there).  There's a style auto-description to use the second form to
document the option itself (it's not really clear this is useful as an
end-user option rather than an _arguments option except for the not very
helpful reason that people writing completions would forget to use it).
There's nothing to stop both forms from being present.

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-22 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-22  3:38 [PATCH] _xargs: add many options Benjamin R. Haskell
2010-03-22 10:40 ` Peter Stephenson

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).