Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _unace



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

#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(-.)"'


Messages sorted by: Reverse Date, Date, Thread, Author