Rewrite Zsh completion
[pkgusr] / etc / pkgusr / zsh / _zsh-pkgtools
index ac71782..769106e 100644 (file)
@@ -1,9 +1,27 @@
-#compdef ppkg cpkg dpkg upkg vpkg ipkg gpkg wpkg pkgrepo pkgsu pkgwant xtar vtar
+#compdef cpkg dpkg fpkg gpkg ipkg ppkg upkg vpkg wpkg pkgrepo pkgsu pkgwant vtar xtar
 
-case $service in
-        (cpkg) _command_names -e ;;
-        (?pkg) _wanted file expl 'Pkg User' _users ;;
-        (pkgrepo|pkgsu|pkgwant) _wanted file expl 'Pkg User' _users ;;
-        ([xv]tar) _wanted file expl 'Tarball' _files -g '*.{t{gz,bz{,2},lz,xz},tar.{Z,gz,bz2,lzma,xz}}(-.)' ;;
-esac
+_pkgtools_users()
+{
+    compadd "$@" - $(awk -F: '/^install/ {print $4;}' /etc/group|tr -s , ' ')
+}
 
+_zsh-pkgtools()
+{
+    local curcontext="$curcontext" state line expl
+    typeset -A opt_args
+
+    case $service in
+            (cpkg) _command_names -e ;;
+       (?pkg|pkg*) _arguments -C -s ':Package User:_pkgtools_users' ;;
+         ([xv]tar) _wanted file expl 'Tarball' _files -g \
+             '*.{t{gz,bz{,2},lz,xz},tar.{Z,gz,bz2,lzma,xz}}(-.)' ;;
+    esac
+}
+
+_zsh-pkgtools "$@"
+
+# Local Variables:
+# mode: Shell-Script
+# sh-indentation: 4
+# sh-basic-offset: 4
+# End: