* _auto-apt
@ 2002-05-21 15:34 Bruno Bonfils
2002-05-21 16:03 ` _auto-apt Oliver Kiddle
0 siblings, 1 reply; 2+ messages in thread
From: Bruno Bonfils @ 2002-05-21 15:34 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1: Type: text/plain, Size: 446 bytes --]
Hi all,
i attach the _auto-apt completion function that just i finish to
write. But i still have one problem :
_wanted distribution expl 'distribution' compadd -q -S, $distribs
as you can see, user can use one or many distrubitions, comma
separated, thats why i add the -S, So, when i a do
auto-apt -a <tab>
i have the completion for main,contrib,non-free,etc..., but :
auto-apt -a main,<tab> do nothing
I hope you can help me. Regards
[-- Attachment #2: auto-apt completion fonction --]
[-- Type: application/octet-stream, Size: 1715 bytes --]
#compdef auto-apt
#
# Bruno Bonfils, <asyd@zshfr.or>
#
local expl prev ret
prev="$words[CURRENT-1]"
# if there is a command in arguments ?
if [[ -n $words[(r)(run|update|update-local|merge|del|check|list|search|debuilt|status)] ]] ; then
# yes, add completion for command arguments and command options
if [[ -n $words[(r)(update|update-local|merge)] && "$words[CURRENT]" = -* ]] ; then
_wanted option expl 'option' compadd - "-a" && return 0;
fi
if [[ -n $words[(r)(check|list|search)] && "$words[CURRENT]" = -* ]] ; then
_wanted option expl 'option' compadd - "-v" "-f" && return 0;
fi
case $prev in
"run")
_wanted command expl 'command' _files -g '*(/,*)' && return 0 ;;
"del")
_wanted package expl 'package' _deb_packages avail && return 0 ;;
esac
else
# no, add completion for commands or options (and options arguments)
case $prev in
"-a")
local distribs
distribs=("main" "contrib" "non-free" "non-US" "none")
_wanted distribution expl 'distribution' compadd -q -S, $distribs ;;
"-p")
local hooks
hooks=("exec" "open" "access" "stat" "none")
_wanted hook expl 'hook' compadd -q -S, $hooks ;;
"-D")
_wanted file expl 'dbfile' _files ;;
"-F")
_wanted file expl 'filedb' _files ;;
*)
local commands options
commands=("run" "update" "update-local" "merge" "del" "check" "list" "search" "debuild" "status")
options=("-h" "-s" "-y" "-q" "-i" "-X" "-x" "-a" "-p" "-D" "-F" "-L")
if [[ "$words[CURRENT]" = -* ]] ; then
_wanted option expl 'option' compadd - $options
else
_wanted command expl 'command' compadd $commands
fi
;;
esac
return 0
fi
[-- Attachment #3: Type: text/plain, Size: 148 bytes --]
--
Bruno Bonfils KeyID F39DCCF5
Sys Admin GNU/Linux http://www.debian-fr.org
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: _auto-apt
2002-05-21 15:34 _auto-apt Bruno Bonfils
@ 2002-05-21 16:03 ` Oliver Kiddle
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2002-05-21 16:03 UTC (permalink / raw)
To: Bruno Bonfils; +Cc: zsh-workers
On Tue, May 21, 2002 at 05:34:23PM +0200, Bruno Bonfils wrote:
> i attach the _auto-apt completion function that just i finish to
> write. But i still have one problem :
>
> _wanted distribution expl 'distribution' compadd -q -S, $distribs
>
> as you can see, user can use one or many distrubitions, comma
> separated, thats why i add the -S, So, when i a do
>
> auto-apt -a <tab>
>
> i have the completion for main,contrib,non-free,etc..., but :
>
> auto-apt -a main,<tab> do nothing
That is because it doesn't know that it should ignore the `main,'
for the purposes of matching. By doing:
compset -P '*,'
you could make it chop off everything up to the last comma. You
would also probably want compset -S ',*' so that it works with
tab pressed in the middle of a list.
However, in this instance, it would be much easier to just use
_values -s , 'distribution' $distribs
as _values does all that work for you.
Oliver
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-05-21 16:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-21 15:34 _auto-apt Bruno Bonfils
2002-05-21 16:03 ` _auto-apt Oliver Kiddle
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).