zsh-workers
 help / color / mirror / code / Atom feed
* _unace
@ 2005-03-02 19:19 Henryk Konsek
  2005-03-03 13:36 ` _unace Oliver Kiddle
  0 siblings, 1 reply; 3+ messages in thread
From: Henryk Konsek @ 2005-03-02 19:19 UTC (permalink / raw)
  To: zsh-workers

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

Hi,
 I've written completion file for the unace command. Its syntax is very 
similar to the unrar command so I've used part of _rar as a pattern while 
creating it. This is my first completion file so I would be grateful for any 
comments.
 I hope that I send it to the suittable mailing list :P

 Greetings, HK

[-- Attachment #2: _unace --]
[-- Type: text/plain, Size: 460 bytes --]

#compdef unace

if (( CURRENT == 2)); then
	_values 'unace command' \
	'e[Extract files]' \
	'l[List archive]' \
	't[Test archive integrity]' \
	'v[List archive (verbose)]' \
	'x[Extract files with full path]' \
	&& return 
else
	_arguments -S \
	'-c\ [Show comments]' \
	'-f\ [Full path matching]' \
	'-o\ [Overwrite files]' \
	'-p\<password>[Set <password>]' \
	'-y\ [Assume yes on all queries]' \
	'*:files:_files -g \*.rar\(-.\)\' \
      	 && return 
fi


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

* Re: _unace
  2005-03-02 19:19 _unace Henryk Konsek
@ 2005-03-03 13:36 ` Oliver Kiddle
  2005-03-03 14:16   ` _unace Henryk Konsek
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2005-03-03 13:36 UTC (permalink / raw)
  To: Henryk Konsek; +Cc: zsh-workers

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

Henryk Konsek wrote:
>  I've written completion file for the unace command. Its syntax is very

Thanks for this.

> similar to the unrar command so I've used part of _rar as a pattern while 
> creating it. This is my first completion file so I would be grateful for any 
> comments.

I'll put a few comments below.

> if (( CURRENT == 2)); then

You can actually do this from _arguments directly which has the
advantage that it will then complete unace commands after any switches.
You do this by starting an _arguments specification with a number. For
example:

  '1:unace command:((e\:extract\ files l\:list\ archive))'

The final component of that lets you specify what to complete. The
syntax above with the descriptions is similar in effect to your use of
_values.

>         '-c\ [Show comments]' \

What is the `\ ' in there for?

>         '-p\<password>[Set <password>]' \

If a password is defined after the -p switch, you can use this:
  '-p[specify password]:password' \

It then knows to prompt for a password to be completed after -p. If the
password should be imediately after the `-p' (as with unace) then use a
`+':

  '-p+[specify password]:password' \

>         '*:files:_files -g \*.rar\(-.\)\' \

Don't you mean to complete .ace files instead of .rar?

Also, looking at the output of unace -h, there is also a -x option for
excluding files. It also looks like it should actually complete archive
(.ace) files in the second argument position only and then complete
files from within the archive. _zip does something similar if you want
to have a look.

Also from the unace -h output, it looks like the options need a trailing
`-' or `+' to indicate enabled or disabled. It says:

<Switches>               (default)
  c[-]  Show comments         (+)
  f[-]  Full path matching    (-)
  o[-]  Overwrite files       (-)

Can the defaults be changed? If not, we could just use something like:
  '-c\-[show comments]' \
  '-f\+[full path matching]' \
If the defaults are configurable, we may need:
  '-c+[show comments]:enable:(- +)' \
Or have I misunderstood the output of unace -h?

I've attached an updated version of _unace. I've not actually got any
.ace files to test it on so you can still improve it in some of the ways
I've mentioned.

Oliver


[-- Attachment #2: _unace --]
[-- Type: text/plain, Size: 472 bytes --]

#compdef unace

_arguments -S \
  '-c[show comments]' \
  '-f[full path matching]' \
  '-o[overwrite files]' \
  '-p+[specify password]:password' \
  '-y[assume yes on all queries]' \
  '-x+[specify files to exclude]:files' \
  '-h[print help information]' \
  '1:unace command:((
    e\:extract\ files
    l\:list\ archive
    t\:test\ archive\ integrity
    v\:list\ archive\ \(verbose\)
    x\:extract\ files\ with\ full\ path
  ))' \
  '*:files:_files -g "*.ace(-.)"'

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

* Re: _unace
  2005-03-03 13:36 ` _unace Oliver Kiddle
@ 2005-03-03 14:16   ` Henryk Konsek
  0 siblings, 0 replies; 3+ messages in thread
From: Henryk Konsek @ 2005-03-03 14:16 UTC (permalink / raw)
  To: zsh-workers

On Thursday 03 March 2005 14:36, you wrote:
> I'll put a few comments below.

Thanks for every comment and fixes. I'm gonna train myself in writing 
completions so I hope that my future function will be better :) .

> >         '*:files:_files -g \*.rar\(-.\)\' \
>
> Don't you mean to complete .ace files instead of .rar?

Oh yes, my silly mistake :) .

Greetings, HK


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

end of thread, other threads:[~2005-03-03 14:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-02 19:19 _unace Henryk Konsek
2005-03-03 13:36 ` _unace Oliver Kiddle
2005-03-03 14:16   ` _unace Henryk Konsek

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