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

PATCH: _pkg* completion for Solaris



I've been meaning to write some completion functions for Solaris-specific
utilities and get them added to the zsh distribution if at all possible.
Some I've had written for some time, like the following, which are for the
packaging commands.  I've got some for the SMF and DTrace commands as well,
but they need some more work before they're all that good.

I'm generally writing to the latest Solaris bits (meaning the latest Nevada
bits available through opensolaris).  I'm not sure how best to deal with
the utilities changing through the releases, as most don't have usefully
parseable help outputs.  Perhaps a switch on the uname, assuming that
anything unrecognized is the latest stuff?

Anyway, I'll try to keep these coming.  I'd love to have 'em in by default.

Thanks,
Danek
--- Completion/Solaris/Command/_pkgadd.orig	2005-11-03 18:12:14.000000000 -0800
+++ Completion/Solaris/Command/_pkgadd	2005-11-03 17:57:41.000000000 -0800
@@ -0,0 +1,32 @@
+#compdef pkgadd
+
+_pkgadd_pass() {
+	_values -S : 'password descriptor' \
+	'(file env console)pass[Literal password]:password:' \
+	'(pass file console)env[Environment variable]:environment:_parameters -g "*export*"' \
+	'(pass env console)file[File]:file:_files' \
+	'(pass env file)console[From /dev/tty]'
+}
+
+_pkgadd() {
+	_arguments -s \
+	'-d[Device]:device file:_files' \
+	'-x[HTTP(S) proxy]:HTTP proxy: ' \
+	'-k[Keystore]:keystore:_files' \
+	'-P[Password to decrypt keystore]:password:_pkgadd_pass' \
+	'-Y[Select packages by category]:category: ' \
+	- set1 \
+	'-n[Non-interactive mode]' \
+	'-v[Trace all scripts]' \
+	'-a[Admin file]:admin file:_files' \
+	"-M[Don't use vfstab file]" \
+	'-R[Root path]:root path:_files -/' \
+	'-r[Response file]:response file:_files' \
+	'-V[Alternate vfstab file]:vfstab file:_files' \
+	'*:package instance:_pkg_instance --_opts uninstalled:-d' \
+	- set2 \
+	'-s[Spool package]:spool directory:_files -/' \
+	'*:package instance:_pkg_instance --_opts uninstalled:-d'
+}
+
+_pkgadd "$@"
--- Completion/Solaris/Command/_pkginfo.orig	2005-11-03 18:12:14.000000000 -0800
+++ Completion/Solaris/Command/_pkginfo	2005-11-03 17:57:41.000000000 -0800
@@ -0,0 +1,22 @@
+#compdef pkginfo
+
+_pkginfo() {
+	_arguments -s \
+	'(-q -r -x)-l[Long listing]' \
+	'(-l -r -x)-q[Quiet mode]' \
+	'(-l -q -x)-r[Relocation base]' \
+	'(-l -q -r)-x[Extracted listing]' \
+	'-c[Category]:category: ' \
+	'-a[Architecture]:architecture: ' \
+	'-v[Version]:version: ' \
+	- set1 \
+	'(-p)-i[Select completely installed packages]' \
+	'(-i)-p[Select partially installed packages]' \
+	'-R[Root path]:root path:_files -/' \
+	'*:package instance:_pkg_instance --_opts installed:set1--R' \
+	- set2 \
+	'-d[Device]:device file:_files' \
+	'*:package instance:_pkg_instance --_opts uninstalled:set2--d'
+}
+
+_pkginfo "$@"
--- Completion/Solaris/Command/_pkgrm.orig	2005-11-03 18:12:14.000000000 -0800
+++ Completion/Solaris/Command/_pkgrm	2005-11-03 17:57:41.000000000 -0800
@@ -0,0 +1,20 @@
+#compdef pkgrm
+
+_pkgrm() {
+	_arguments -s \
+	'-Y[Select packages by category]:category: ' \
+	- set1 \
+	'-n[Non-interactive mode]' \
+	'-v[Trace all scripts]' \
+	'-a[Admin file]:admin file:_files' \
+	"-A[Force removal of all files]" \
+	"-M[Don't use vfstab file]" \
+	'-R[Root path]:root path:_files -/' \
+	'-V[Alternate vfstab file]:vfstab file:_files' \
+	'*:package instance:_pkg_instance --_opts installed:set1--R' \
+	- set2 \
+	'-s[Spool package]:spool directory:_files -/' \
+	'*:package instance:_pkg_instance --_opts spooled:set2--s'
+}
+
+_pkgrm "$@"
--- Completion/Solaris/Type/_pkg_instance.orig	2005-11-03 18:12:14.000000000 -0800
+++ Completion/Solaris/Type/_pkg_instance	2005-11-03 17:57:41.000000000 -0800
@@ -0,0 +1,20 @@
+#autoload
+
+local -A opts
+local whicharg
+
+zparseopts -E -D -- '-_opts:=opts'
+
+whicharg=${opts#*:}
+
+case ${opts%:*} in
+(installed)
+	compadd "$@" - ${opt_args[$whicharg]}/var/sadm/pkg/*/pkginfo(:h:t)
+	;;
+(spooled)
+	compadd "$@" - ${opt_args[$whicharg]}/*(:t)
+	;;
+(uninstalled)
+	compadd "$@" - ${opt_args[$whicharg]:-/var/spool/pkg}/*/pkgmap(:h:t)
+	;;
+esac
--- Src/Zle/complete.mdd.orig	2005-01-12 09:29:06.000000000 -0800
+++ Src/Zle/complete.mdd	2005-11-03 18:11:48.000000000 -0800
@@ -1,7 +1,7 @@
 name=zsh/complete
 link=either
 load=yes
-functions='Completion/*comp* Completion/AIX/*/* Completion/BSD/*/* Completion/Base/*/* Completion/Cygwin/*/* Completion/Darwin/*/* Completion/Debian/*/* Completion/Linux/*/* Completion/Mandrake/*/* Completion/Redhat/*/* Completion/Unix/*/* Completion/X/*/* Completion/Zsh/*/*'
+functions='Completion/*comp* Completion/AIX/*/* Completion/BSD/*/* Completion/Base/*/* Completion/Cygwin/*/* Completion/Darwin/*/* Completion/Debian/*/* Completion/Linux/*/* Completion/Mandrake/*/* Completion/Redhat/*/* Completion/Solaris/*/* Completion/Unix/*/* Completion/X/*/* Completion/Zsh/*/*'
 
 moddeps="zsh/zle"
 


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