Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] OpenSolaris IPS completion 2.0 (complete rewrite/almost complete)
- X-seq: zsh-workers 25664
- From: "xRaich[o]²x" <raichoo@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: [PATCH] OpenSolaris IPS completion 2.0 (complete rewrite/almost complete)
- Date: Sun, 14 Sep 2008 03:32:04 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:user-agent :mime-version:to:subject:content-type:content-transfer-encoding:from; bh=mt29NFo7sJNZjDRz4j/RNx3Hpm4qvLmA11eDRgyUqek=; b=jEKHj0ZAByNI21qUc6Uk9Q2mFbMIXR0PgPcqVlQKAZr+jt3/LThhMUNV6dTDf/SvT9 Rel8DeIL5VkKpbo9/pMLEYLzXf7pQA/9je5NHnSrQ63iUhr1qCk6OTs43eyDfMvLm89s nZapaqoEx0pGhTq4GHlTzaP3fdZaGQfVeURWg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:user-agent:mime-version:to:subject:content-type :content-transfer-encoding:from; b=EalgV1ty+w0kKqdwcoU8SujHWkP3XWXa5VOyzZ522ogoxbNvxwhbiIwUr361JGCjTU jgxqqvbEuJmdWrtclZD79K0lANkVy5lGcycyfNawlFqyMCaYGCV2iHXvQCkdVj9nwFnw G8Hn9a+MxF4xVhvO732lg8ftMCZaB8/AusRbo=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Hi,
I rewrote the script i sent yesterday. This one is almost complete and
uses more of the compsys abilities. Would be cool if someone could help
me on the other options.
Regards,
Björn
#compdef pkg
local state
ret=1
_arguments -s '-R[image]:image:_directories' '*::command:->command' && ret=0
#TODO use pkg interface
function all_packages
{
compadd $(awk '{print $3}' $(find /var/pkg/catalog -name catalog
-type f) | sort -u)
}
function installed_packages
{
compadd $(/usr/bin/ls /var/pkg/state/installed | cut -d@ -f1)
}
function get_auth
{
compadd $(find /var/pkg/catalog/ -type d | sed 1d | cut -d/ -f5) &&
ret=0
}
while [[ -n "$state" ]]; do
tmp=$state
state=
case $tmp in
command)
if (( CURRENT == 1 )); then
state=subcommands
else
echo ${words[1]} ${tmp} > /dev/pts/6
cmd="$words[1]"
curcontext="${curcontext%:*:*}:pkg-${cmd}:"
case $cmd in
install)
_arguments -s \
'-n[no changes]::all_packages' \
'-v[verbose]::all_packages' \
'-q[quiet]::all_packages' \
'*::command:all_packages' && ret=0
;;
uninstall)
_arguments -s \
'-n[no changes]::installed_packages' \
'-v[verbose]::installed_packages' \
'-q[quiet]::installed_packages' \
'-r[recursive]::installed_packages' \
'*::command:installed_packages' && ret=0
;;
search)
_arguments -s \
'-l[local search]' \
'-r[remote search]' \
'-I[case sensitive]' && ret=0
;;
info)
_arguments \
'-l[local package]::installed_packages' \
'-r[remote package]::all_packages' \
'*::command:installed_packages' && ret=0
#TODO --license
;;
verify)
_arguments \
'-v[verbose]::installed_packages' \
'-H[omit headers]::installed_packages' \
'-q[quiet]::installed_packages' \
'*::command:installed_packages' && ret=0
;;
contents)
_arguments -s \
'-r[remote package]::all_packages' \
'-H[omit headers]::installed_packages' \
'-m[bla]::installed_packages' \
'*::command:installed_packages' && ret=0
#TODO rest of options
;;
list)
_arguments -s \
'-a[all]::all_packages' \
'-H[omit header]::all_packages' \
'-s[display short-form]::all_packages' \
'-u[display only newer packages]::all_packages' \
'-v[display full FMRI]::all_packages' \
'*::command:all_packages' && ret=0
;;
image-update)
_arguments -s \
'-n[no changes]' \
'-v[verbose]' \
'-q[quite]' && ret=0
;;
authority)
_arguments -s \
'-H[omit header]::get_auth' \
'-P[]::get_auth' \
'*::command:get_auth' && ret=0
;;
unset-authority)
get_auth && ret=0
;;
refresh)
_arguments -s \
'--full[full refresh]::get_auth' \
'*::command:get_auth' && ret=0
;;
image-create)
#TODO options
;;
set-authority)
_arguments '-O[origin URL]'
#TODO rest of options
;;
rebuild-index|version|help)
;;
esac
fi
;;
subcommands)
cmds=(
'install:install a package'
'uninstall:uninstall a package'
'verify:verify a package'
'info:fetch package info'
'contents:show package contents'
'list:list installed packages'
'search:search for a package'
'refresh:refresh catalogues'
'image-create:create new image'
'image-update:update an image'
'set-authority:set an authority'
'unset-authority:unset an authority'
'authority:list authorities'
'rebuild-index:rebuild index'
)
_describe 'pkg command' cmds -- && ret=0
;;
esac
done
#clean up
unfunction installed_packages
unfunction all_packages
unfunction get_auth
return ret
Messages sorted by:
Reverse Date,
Date,
Thread,
Author