summaryrefslogtreecommitdiff
path: root/src/query.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-06-20 00:08:10 +0100
committerdavidovski <david@davidovski.xyz>2022-06-20 00:08:10 +0100
commit786633be3f57f66eecaa5534f0a9703373439138 (patch)
tree1c11c868f0d15aa046ee127b0b9f079798d21f0d /src/query.sh
parent1c930ef3795800b6897bfa64afb52b3104edf22b (diff)
added size command
Diffstat (limited to 'src/query.sh')
-rw-r--r--src/query.sh23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/query.sh b/src/query.sh
index aff4512..9531a29 100644
--- a/src/query.sh
+++ b/src/query.sh
@@ -78,6 +78,7 @@ extract_info () {
#
print_info () {
file=$1
+ name=$(extract_info $file "NAME")
line="${LIGHT_CYAN}%-15s ${LIGHT_BLUE}%s\n"
for field in Name Description Version; do
printf "$line" "$field" "$(extract_info $file $field)"
@@ -86,9 +87,10 @@ print_info () {
printf "$line" "Dependencies" "$(extract_info $file "DEPS")"
printf "$line" "Build Date" "$(extract_info $file "DATE")"
- is_installed $(extract_info $file "NAME") && {
+ is_installed $name && {
date=$(date -d @$(stat -t $file | cut -d' ' -f13))
printf "$line" "Install Date" "$date"
+ printf "$line" "Install Size" "$(QUIET=true size_of $name)"
} || true
}
@@ -100,7 +102,24 @@ info () {
[ -f $infofile ] && {
print_info $infofile
} || {
- printf "Package info for $package could not be found!"
+ printf "Package info for $package could not be found!\n"
}
done
}
+
+# get the size of a package
+#
+size_of () {
+ local size=0 file=
+ for file in $(files $@); do
+ $VERBOSE && printf "${BLACK}file $file "
+ [ -f "$file" ] && {
+ set -- $(stat -t $file)
+ $VERBOSE && printf "has size $2"
+ size=$((size+$2))
+ }
+ $VERBOSE && printf "\n"
+ done
+ echo $size
+}
+