zsh-workers
 help / color / mirror / code / Atom feed
From: "\"xRaich[o]²x\"" <raichoo@googlemail.com>
To: zsh-workers@sunsite.dk
Subject: [PATCH] completion for opensolaris IPS package manager
Date: Sat, 13 Sep 2008 17:21:22 +0200	[thread overview]
Message-ID: <48CBDA72.8090105@gmail.com> (raw)

I started working on some scripts for opensolaris commands (zpool, zfs, 
beadm and more are in the works). Here is the first for package 
management. It's still pretty basic but supports the features that are 
used the most (or at least i use the most ^^)

#compdef pkg

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'
)

_pkg () {
    ret=1
    SHIFTER=0
    if [[ $words[2] == "-R" ]]; then
        if (( CURRENT == 3 )); then
            _directories && ret=0
            return ret
        elif (( CURRENT >= 4 )); then
            SHIFTER=2
        fi
    fi

    if (( CURRENT-SHIFTER == 2 )); then
        _describe 'pkg command' cmds && ret=0
    else
        case ${words[$(( 2 + SHIFTER ))]} in
            install)
                compadd $(awk $'{print $3}' $(find /var/pkg/catalog 
-name catalog -type f) | sort -u) && ret=0
                ;;
            uninstall|verify)
                compadd $(/usr/bin/ls /var/pkg/state/installed | cut -d@ 
-f1) && ret=0
                ;;
            search|info|contents)
                if [[ $words[$(( 3 + SHIFTER ))] == "-r" ]]; then
                    compadd  $(awk $'{print $3}' $(find /var/pkg/catalog 
-name catalog -type f) | sort -u) && ret=0
                else
                    compadd  $(/usr/bin/ls /var/pkg/state/installed | 
cut -d@ -f1) && ret=0
                fi
                ;;
            refresh|unset-authority)
                compadd $(find /var/pkg/catalog/ -type d | sed 1d | cut 
-d/ -f5) && ret=0
        esac
    fi
    return ret
}

Regards,
Björn


             reply	other threads:[~2008-09-13 15:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-13 15:21 "xRaich[o]²x" [this message]
2008-09-13 15:58 ` Danek Duvall
2008-09-13 16:27   ` "xRaich[o]²x"
2008-09-13 16:49     ` Danek Duvall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48CBDA72.8090105@gmail.com \
    --to=raichoo@googlemail.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).