zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] completion for opensolaris IPS package manager
@ 2008-09-13 15:21 "xRaich[o]²x"
  2008-09-13 15:58 ` Danek Duvall
  0 siblings, 1 reply; 4+ messages in thread
From: "xRaich[o]²x" @ 2008-09-13 15:21 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-09-13 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-13 15:21 [PATCH] completion for opensolaris IPS package manager "xRaich[o]²x"
2008-09-13 15:58 ` Danek Duvall
2008-09-13 16:27   ` "xRaich[o]²x"
2008-09-13 16:49     ` Danek Duvall

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