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

Re: GPG completion function



Bruno Bonfils wrote:
> 
> i submit you my first completion function (for gpg)
> 
> i don't have finish completely, but i send you in order
> to have comments/idea.

Looks good. Let us know when it is finished and we can include it in
the distribution.

> _any_ comments/ideas are welcome

Mainly it looks fine. I've added a few comments though within limits as
I'm not familiar with usage of gpg.

> local context state line

You only need these declared if you use states with _arguments. With -C
to _arguments the form would be slightly different actually. I suspect
the final version may use states though.

> typeset -A opt_args

I think you only need this if you're going to use it.

> 	local keys_list

You don't need that any more but `name' needs to be declared local.

> 	# i must rewrite this line using pattern matching
> 	for name in `gpg --list-keys | awk  '/^pub/ { print $NF }' | tr "<|>" -d`
> 	do	
> 		compadd "$name";
> 	done

As you say in the comment this could be rewritten with a zsh
substitution using pattern matching.  You then shouldn't need the for
loop. It could do with then using _wanted with the compadd to assign a
tag and description. Also, you will need to redirect stderr from gpg
--list-keys so anyone who hasn't used gpg ever will get nothing
completed instead of error messages.

> _arguments -C -s	\
> 	'-a[create ASCII armored output]' \
> 	'-o[write output to file]:_files attachment:_files' \

Your description on that line and others is messed up. I'd need to know
more about gpg usage but the file attachment maybe could be completed
with a '1' or '*' spec to _arguments.

> 	'-u[use name as the user ID to sign]'\

I think that needs to be -u+[... The plus indicates that the username
can be specified imediately after -u without a space, or a space can be
used.

> 	'-s[sign a file]:file attachment:_files' \

I see that options like this have a long form as well. Zsh 4.1.x can
recognise this and list them together so I'd suggest using something
like: '(-s --sign)'{-s,--sign}'[sign a file]:file attachment:_files'

It seems that you still have a few gpg options to add to it. There are
also
no exclusion lists - I take it that -e and -s can not be used together
for example.

I hope that is helpful

Oliver

_____________________________________________________________________
This message has been checked for all known viruses by the 
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp



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