From 5225b8a61eb4f3d4ccfc4ae8ce191ff759294b92 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 29 Sep 2009 16:46:00 +0200 Subject: Began mking ct add/remove wrappable (accept more than one package argument) --- bin/ct | 48 +++++++++++++++++++++++++++++++------------- man/1/ct.pod | 8 ++++---- provides/zsh/completions/_ct | 4 ++++ 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/bin/ct b/bin/ct index 8ac6bbf..8e4fc05 100755 --- a/bin/ct +++ b/bin/ct @@ -663,27 +663,47 @@ function apply_triggers { # Iterate a function over every installed package function wrap { + typeset -i loop_all=0 + + while [[ $1 == -* ]] { + case $1 in + -a) loop_all=1 ;; + esac + shift + } + typeset function=$1 - typeset arg=$2 - typeset progress=$3 - typeset i + typeset progress=$2 + typeset package typeset -i all current + typeset -a packages + shift 2 - if [[ -n $2 ]] { - $function $2 + if (( $# == 1 )) { + $function $1 } else { + function wrap_info { clear_line info "$1: " } + + if (( loop_all )) { + packages=(*(-/)) + } else { + packages=($*) + } + [[ -n $progress ]] && all=$(list_packages_local | wc -l) [[ -n $progress ]] && current=0 - for package in *(-/); { + + for package in $packages; { cd $PKG_DIR (( current++ )) - [[ -n $progress ]] && progress $current $all $progress $package + [[ -n $progress && $loop_all == 1 ]] && progress $current $all $progress $package $function $package } + [[ -n $progress ]] && clear_line } } @@ -907,7 +927,6 @@ cd $PKG_DIR || die "Cannot cd $PKG_DIR" # Note: # wrap foobar "$1" <- the "" are neccessary here, since $1 is optional (and therefore may be empty) case $action in - a|add) pkg_add $* ;; debug) pkg_debug $* ;; e|eval) eval $* ;; i|info) pkg_info $* ;; @@ -916,17 +935,18 @@ case $action in f|pull) (( AUTOUPDATE )) && pkg_update remote - wrap pkg_upgrade "$1" 'Looking for updates' + wrap -a pkg_upgrade 'Looking for updates' $* ;; p|push) (( AUTOUPDATE )) && pkg_update - wrap pkg_push "$1" 'Pushing' + wrap -a pkg_push 'Pushing' $* ;; - r|refresh) wrap pkg_refresh "$1" 'Refreshing' ;; - rm|remove) pkg_remove $* ;; - s|status) wrap pkg_status "$1" 'Checking package status' ;; - u|update) pkg_update $* ;; + a|add) wrap pkg_add 'Adding' $* ;; + r|refresh) wrap -a pkg_refresh 'Refreshing' $* ;; + rm|remove) wrap pkg_remove 'Removing' $* ;; + s|status) wrap -a pkg_status 'Checking package status' $* ;; + u|update) pkg_update $* ;; *) die "wait, what?\nct: unknown action: '$action'\n" ;; esac diff --git a/man/1/ct.pod b/man/1/ct.pod index b73d403..cdea7e7 100644 --- a/man/1/ct.pod +++ b/man/1/ct.pod @@ -14,9 +14,9 @@ I may be one of: =over -=item B I +=item B I -fetch I from the package_root and install it +fetch I from the package_root and install it =item B @@ -70,9 +70,9 @@ If no argument is given, pushes all installed packages Check prereqs and update symlinks of I. If no argument is given, refreshs all installed packages -=item B I +=item B I -Remove I from the local packages tree +Remove I from the local packages tree =item B [ I ] diff --git a/provides/zsh/completions/_ct b/provides/zsh/completions/_ct index 29625a5..0d0b105 100644 --- a/provides/zsh/completions/_ct +++ b/provides/zsh/completions/_ct @@ -71,6 +71,10 @@ function _ct_args { ;; esac } + } elif [[ ${words[1]} == (a|add) ]] { + _ct_notinstalled + } elif [[ ${words[1]} == (rm|remove) ]] { + _ct_installed } } -- cgit v1.2.3