summaryrefslogtreecommitdiffstats
path: root/examples/tools/mail.sh
diff options
context:
space:
mode:
Diffstat (limited to 'examples/tools/mail.sh')
-rwxr-xr-xexamples/tools/mail.sh11
1 files changed, 7 insertions, 4 deletions
diff --git a/examples/tools/mail.sh b/examples/tools/mail.sh
index 4e0e9c1..bd7219d 100755
--- a/examples/tools/mail.sh
+++ b/examples/tools/mail.sh
@@ -23,8 +23,11 @@
set -uo pipefail
query="${1:-tag:unread and tag:inbox}"
-json=$("${MAILCTL:-mailctl.py}" search "$query" --json) || { echo "mail search failed" >&2; exit 1; }
-jq -r 'length as $n
- | if $n == 0 then "no threads match"
- else "\($n) threads", (.[:10][] | "\(.date_relative), \(.authors): \(.subject)")
+mailctl="${MAILCTL:-mailctl.py}"
+json=$("$mailctl" search "$query" --json) || { echo "mail search failed" >&2; exit 1; }
+# Messages and threads both: the model otherwise calls threads "emails".
+msgs=$("$mailctl" count "$query" | awk '{print $1}') || { echo "mail count failed" >&2; exit 1; }
+jq -r --arg msgs "$msgs" 'length as $n
+ | if $n == 0 then "no messages match"
+ else "\($msgs) messages in \($n) threads", (.[:10][] | "\(.date_relative), \(.authors): \(.subject)")
end' <<<"$json"