From 7e6b592744f31ab43553e7c8246b30def5c47a90 Mon Sep 17 00:00:00 2001
From: merakor <cem@ckyln.com>
Date: Tue, 20 Oct 2020 11:33:12 +0000
Subject: cpt-size: add ability to check the size of multiple packages

FossilOrigin-Name: 48470adaaeb2d09a0cbbf6eb13463d2e231555d592225496c778281ba1b173de
---
 contrib/cpt-size | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

(limited to 'contrib/cpt-size')

diff --git a/contrib/cpt-size b/contrib/cpt-size
index f55f72a..0e7b9d6 100755
--- a/contrib/cpt-size
+++ b/contrib/cpt-size
@@ -3,21 +3,23 @@
 
 case "$1" in
     --help|-h)
-        printf '%s\n' "usage: ${0##*/} [pkg]"
+        printf '%s\n' "usage: ${0##*/} [pkg...]"
         exit 0
         ;;
     '') set -- "${PWD##*/}"
 esac
 
-cpt-search "$1" >/dev/null
+for pkg; do cpt-list "$pkg" >/dev/null; done
 
 files=
-while read -r file; do
-    # Filter directories from manifest and leave only files.
-    # Directories in the manifest end in a trailing '/'.
-    case $file in */) continue; esac
-    files="$files '$file'"
-done < "$CPT_ROOT/var/db/cpt/installed/$1/manifest"
+for pkg; do
+    while read -r file; do
+        # Filter directories from manifest and leave only files.
+        # Directories in the manifest end in a trailing '/'.
+        case $file in */) continue; esac
+        files="$files '$file'"
+    done < "$CPT_ROOT/var/db/cpt/installed/$pkg/manifest"
+done
 eval "set -- $files"
 
 # Send the file list to 'du'.
-- 
cgit v1.2.3