zsh-users
 help / color / mirror / code / Atom feed
* completion for rsync?
@ 2002-01-22 19:19 Anthony R Iano-Fletcher
  2002-01-22 19:54 ` Bart Schaefer
  2002-01-23  8:40 ` Sven Wischnowsky
  0 siblings, 2 replies; 6+ messages in thread
From: Anthony R Iano-Fletcher @ 2002-01-22 19:19 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 425 bytes --]

Hello All,

	Does anyone have a new style completion function (_rsync) for rsync?
By the way, I made one for fping - maybe it could be added to the
distribution.

			Anthony.

-- 
Anthony R Iano-Fletcher        Anthony.Iano-Fletcher@nih.gov
                               http://cbel.cit.nih.gov/~arif
                               CBEL, CIT, NIH, Bethesda, MD, USA.
                               Phone: (+1) 301 402 1741.

[-- Attachment #2: _fping --]
[-- Type: text/plain, Size: 1496 bytes --]

#compdef fping

local expl hosts

_arguments -C \
   '-a[show targets that are alive]:' \
   '-A[show targets by address]:' \
   '-v[show version]:' \
   '-b n[amount of ping data to send, in bytes (default 56)]:' \
   '-B f[set exponential backoff factor to f]:' \
   '-c n[count of pings to send to each target (default 1)]:' \
   '-C n[same as -c, report results in verbose format]:' \
   '-e[show elapsed time on return packets]:' \
   '-f[read list of targets from a file ( - means stdin)]:_file' \
   '-i n[interval between sending ping packets (in millisec) (default 25)]:' \
   '-l[loop sending pings forever]:' \
   '-m[ping multiple interfaces on target host]:' \
   '-n[show targets by name (-d is equivalent)]:' \
   '-p n[interval between ping packets to one target (in millisec) (in looping and counting modes, default 1000)]:' \
   '-q[quiet (dont show per-target/per-ping results)]:' \
   '-Q n[same as -q, but show summary every n seconds]:' \
   '-r n[number of retries (default 3)]:' \
   '-s[print final stats]:' \
   '-t n[individual target initial timeout (in millisec) (default 500)]:' \
   '-u[show targets that are unreachable]:' \
   && ret=0

if ! zstyle -a ":completion:${curcontext}:hosts" hosts hosts; then
  (( $+_cache_hosts )) ||
      : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}

  hosts=( "$_cache_hosts[@]" )
fi

_wanted hosts expl host \
    compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" -a hosts


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

* Re: completion for rsync?
  2002-01-22 19:19 completion for rsync? Anthony R Iano-Fletcher
@ 2002-01-22 19:54 ` Bart Schaefer
  2002-01-23  8:40 ` Sven Wischnowsky
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2002-01-22 19:54 UTC (permalink / raw)
  To: Anthony R Iano-Fletcher, zsh-users

On Jan 22,  2:19pm, Anthony R Iano-Fletcher wrote:
} 
} Does anyone have a new style completion function (_rsync) for rsync?

There's one in the development version -- if you can't grab it from CVS
on SourcForge, drop me a note and I'll send it to you.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

* Re: completion for rsync?
  2002-01-22 19:19 completion for rsync? Anthony R Iano-Fletcher
  2002-01-22 19:54 ` Bart Schaefer
@ 2002-01-23  8:40 ` Sven Wischnowsky
  2002-01-23 15:02   ` Anthony R Iano-Fletcher
  1 sibling, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2002-01-23  8:40 UTC (permalink / raw)
  To: zsh-users


Anthony R Iano-Fletcher wrote:

> ...
> 
> #compdef fping
> 
> local expl hosts
> 
> _arguments -C \
> ...
>    '-u[show targets that are unreachable]:' \
>    && ret=0

Shouldn't the follwing be replaced by an argument-spec calling _hosts
(it's the same code anyway) and the `&& ret=0' be removed (it's not
defined as a local and not initialised to `1')?

> if ! zstyle -a ":completion:${curcontext}:hosts" hosts hosts; then
>   (( $+_cache_hosts )) ||
>       : ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
> 
>   hosts=( "$_cache_hosts[@]" )
> fi
> 
> _wanted hosts expl host \
>     compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" -a hosts



Bye
  Sven

-- 
Sven Wischnowsky                           wischnow@berkom.de


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

* Re: completion for rsync?
  2002-01-23  8:40 ` Sven Wischnowsky
@ 2002-01-23 15:02   ` Anthony R Iano-Fletcher
  2002-01-23 15:23     ` Sven Wischnowsky
  0 siblings, 1 reply; 6+ messages in thread
From: Anthony R Iano-Fletcher @ 2002-01-23 15:02 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-users

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

Hello 

Thank you, Sven, for your comments.

> > #compdef fping
> > 
> > 
> > _arguments -C \
> > ...
> >    '-u[show targets that are unreachable]:' \
> >    && ret=0
> 
> Shouldn't the follwing be replaced by an argument-spec calling _hosts
> (it's the same code anyway) and the `&& ret=0' be removed (it's not
> defined as a local and not initialised to `1')?

I removed the '&& ret=0'. I followed the recipe from another completion
function... hence the extra cruft. Likewise I have some extra colons in
the options.

You mean something like:
	_wanted hosts expl 'host name' _hosts
That does work better.....

I'm attaching the next version...... criticism is welcome.

Do I still need this line?
> > local expl hosts

I am just starting to get to grips with the new completion stuff after
putting it off for years. You've all done a great job with the default
completions that most of the job is done. Thanks.

			Anthony.

-- 
Anthony R Iano-Fletcher        Anthony.Iano-Fletcher@nih.gov
                               http://cbel.cit.nih.gov/~arif
                               CBEL, CIT, NIH, Bethesda, MD, USA.
                               Phone: (+1) 301 402 1741.

[-- Attachment #2: _fping --]
[-- Type: text/plain, Size: 1185 bytes --]

#compdef fping

local expl hosts

_arguments -C \
   '-a[show targets that are alive]' \
   '-A[show targets by address]' \
   '-v[show version]' \
   '-b n[amount of ping data to send, in bytes (default 56)]:' \
   '-B f[set exponential backoff factor to f]:' \
   '-c n[count of pings to send to each target (default 1)]:' \
   '-C n[same as -c, report results in verbose format]:' \
   '-e[show elapsed time on return packets]' \
   '-f[read list of targets from a file ( - means stdin)]:_file' \
   '-i n[interval between sending ping packets (in millisec) (default 25)]:' \
   '-l[loop sending pings forever]' \
   '-m[ping multiple interfaces on target host]' \
   '-n[show targets by name (-d is equivalent)]' \
   '-p n[interval between ping packets to one target (in millisec) (in looping and counting modes, default 1000)]:' \
   '-q[quiet (dont show per-target/per-ping results)]' \
   '-Q n[same as -q, but show summary every n seconds]:' \
   '-r n[number of retries (default 3)]:' \
   '-s[print final stats]' \
   '-t n[individual target initial timeout (in millisec) (default 500)]:' \
   '-u[show targets that are unreachable]'

_wanted hosts expl 'host name' _hosts


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

* Re: completion for rsync?
  2002-01-23 15:02   ` Anthony R Iano-Fletcher
@ 2002-01-23 15:23     ` Sven Wischnowsky
  2002-01-23 15:38       ` completion for fping (not rsync)? Anthony R Iano-Fletcher
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 2002-01-23 15:23 UTC (permalink / raw)
  To: zsh-users


Anthony R Iano-Fletcher wrote:

> ...
> 
> I removed the '&& ret=0'. I followed the recipe from another completion
> function... hence the extra cruft. Likewise I have some extra colons in
> the options.
> 
> You mean something like:
> 	_wanted hosts expl 'host name' _hosts
> That does work better.....

No, just the simple:

 _arguments ... \ # option descriptions here
            '*:host name:_hosts'

and nothing below that.  But of course, that can only be a first try
at _rsync, given its complicated syntax, not all of which can be done
with _arguments. So there probably should be either a state handling
or a local utility function (called instead of the _hosts above) to
handle the `[user@]host:(:|)(src|dest)' syntax.  For some of this,
there are already utility functions, looking at how _ssh handles scp
might help here.


> I'm attaching the next version...... criticism is welcome.
> 
> Do I still need this line?
> > > local expl hosts

With the change I described above: no.  In your version `expl' is
still used (second argument to _wanted).


Bye
  Sven

-- 
Sven Wischnowsky                           wischnow@berkom.de


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

* Re: completion for fping (not rsync)?
  2002-01-23 15:23     ` Sven Wischnowsky
@ 2002-01-23 15:38       ` Anthony R Iano-Fletcher
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony R Iano-Fletcher @ 2002-01-23 15:38 UTC (permalink / raw)
  To: Sven Wischnowsky; +Cc: zsh-users

Sorry, I seem to have confused the waters here. The completion I threw
out was for fping. I downloaded the completion for rsync but haven't
spent much time on it yet.

> > You mean something like:
> > 	_wanted hosts expl 'host name' _hosts
> > That does work better.....

> No, just the simple:
> 
>  _arguments ... \ # option descriptions here
>             '*:host name:_hosts'
> 

Brilliant. Thanks.....

> and nothing below that.  But of course, that can only be a first try
> at _rsync, given its complicated syntax, not all of which can be done
> with _arguments. So there probably should be either a state handling
> or a local utility function (called instead of the _hosts above) to
> handle the `[user@]host:(:|)(src|dest)' syntax.  For some of this,
> there are already utility functions, looking at how _ssh handles scp
> might help here.

yes this would be for rsync..... I'll work on that this afternoon. I was
going to peek at _scp, etc.. I did notice that _rsync seems to be
only half done.

			Thanks, Anthony.

-- 
Anthony R Iano-Fletcher        Anthony.Iano-Fletcher@nih.gov
                               http://cbel.cit.nih.gov/~arif
                               CBEL, CIT, NIH, Bethesda, MD, USA.
                               Phone: (+1) 301 402 1741.


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

end of thread, other threads:[~2002-01-23 15:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-22 19:19 completion for rsync? Anthony R Iano-Fletcher
2002-01-22 19:54 ` Bart Schaefer
2002-01-23  8:40 ` Sven Wischnowsky
2002-01-23 15:02   ` Anthony R Iano-Fletcher
2002-01-23 15:23     ` Sven Wischnowsky
2002-01-23 15:38       ` completion for fping (not rsync)? Anthony R Iano-Fletcher

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