From f66d76f4414111f79dc73eb0f8b76f12741b4b81 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 4 Apr 2009 21:56:55 +0200 Subject: pkg: pkg_list: Also list not-installed packages, depending on argument --- bin/pkg | 19 +++++++++++++++---- man/1/pkg | 21 +++++++++++++++------ provides/zsh/completions/_pkg | 12 ++++++++---- 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/bin/pkg b/bin/pkg index 965af60..55f493d 100755 --- a/bin/pkg +++ b/bin/pkg @@ -706,8 +706,20 @@ function pkg_upgrade { fi } -function pkg_list_installed { - cut -d ' ' -f 1 $PDIR/.list +function pkg_list { + case $1 in + ''|local) + cut -d ' ' -f 1 $PDIR/.list + ;; + all|remote) + cut -d ' ' -f 1 $PDIR/.list-remote + ;; + not-installed) + while read package crap; do + grep "^$package" $PDIR/.list &> /dev/null || echo $package + done < $PDIR/.list-remote + ;; + esac } function pkg_list_available { @@ -833,8 +845,7 @@ case $action in delete) pkg_remove $* ;; info) pkg_info $* ;; install) pkg_add $* ;; - list) pkg_list_installed $* ;; - list-all) pkg_list_available $* ;; + list) pkg_list $* ;; local-update) pkg_update_local $* ;; log) pkg_log $* ;; push) diff --git a/man/1/pkg b/man/1/pkg index 1cf823c..56e8dae 100644 --- a/man/1/pkg +++ b/man/1/pkg @@ -32,16 +32,25 @@ Evauluate I. See the 'Examples' section and pkg(7) Show information on I, like dependencies, version, etc -=item B +=item B [I] -List all installed packages +List packages depending on I: -=item B +=over + +=item * B + +show all packages + +=item * B -List all available (both installed and not installed packages +show currently installed packages (default) -Hint: C will show all packages -that are currently not installed +=item * B + +show remote packages which are not installed + +=back =item B diff --git a/provides/zsh/completions/_pkg b/provides/zsh/completions/_pkg index b28b1b3..e0d0b00 100644 --- a/provides/zsh/completions/_pkg +++ b/provides/zsh/completions/_pkg @@ -9,23 +9,23 @@ typeset expl function _pkg_action () { _wanted action expl 'action' \ - compadd add install delete eval remove info list{,-all} \ + compadd add install delete eval remove info list \ local-update log pull push remote-update refresh status update upgrade } function _pkg_installed () { _wanted package expl 'local package' \ - compadd $(pkg list) + compadd $(pkg list local) } function _pkg_all () { _wanted package expl 'package' \ - compadd $(pkg list-all) + compadd $(pkg list all) } function _pkg_notinstalled () { _wanted package expl 'remote package' \ - compadd $(diff <(pkg list) <(pkg list-all) | grep "^>" | cut -d " " -f 2) + compadd $(pkg list remote) } function _pkg_args { @@ -46,6 +46,10 @@ function _pkg_args { compadd $(grep -E '^\S*\s*\(\)\s*{' =pkg | cut -d ' ' -f 1) \ $(grep -E 'function \S* (\(\) )?{' =pkg | cut -d ' ' -f 2) ;; + list) + _wanted something expl 'list mode' \ + compadd all local remote + ;; *) _message 'no more arguments' ;; -- cgit v1.2.3