summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/ct48
-rw-r--r--man/1/ct.pod8
-rw-r--r--provides/zsh/completions/_ct4
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<action> may be one of:
=over
-=item B<add> I<package>
+=item B<add> I<packages>
-fetch I<package> from the package_root and install it
+fetch I<packages> from the package_root and install it
=item B<debug>
@@ -70,9 +70,9 @@ If no argument is given, pushes all installed packages
Check prereqs and update symlinks of I<package>.
If no argument is given, refreshs all installed packages
-=item B<remove> I<package>
+=item B<remove> I<packages>
-Remove I<package> from the local packages tree
+Remove I<packages> from the local packages tree
=item B<status> [ I<package> ]
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
}
}