From 226660f1cacd54915d60f5b5ae13c43ff6ecb046 Mon Sep 17 00:00:00 2001 From: Kirill Bezuglyi Date: Tue, 23 Jul 2024 01:47:22 +0300 Subject: [PATCH] feat: implement `makoctl count` with variants --- makoctl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/makoctl b/makoctl index 041abec..a236b1e 100755 --- a/makoctl +++ b/makoctl @@ -4,6 +4,7 @@ usage() { echo "Usage: makoctl [options...]" echo "" echo "Commands:" + echo " count [waiting|history] Show the number of notifications" echo " dismiss [-n id] Dismiss the notification with the" echo " given id, or the last notification" echo " if none is given" @@ -56,6 +57,24 @@ if [ $# -eq 0 ]; then fi case "$1" in +"count") + require_jq + if [ $# -gt 1 ]; then + case "$2" in + waiting) + call ListNotifications | jq -re '.data[0] | length' + ;; + history) + call ListHistory | jq -re '.data[0] | length' + ;; + *) + echo >&2 "$0: Expected 'waiting' or 'history' after 'count', got '$2'" + ;; + esac + else + echo >&2 "$0: Expected 'waiting' or 'history' after 'count', got nothing" + fi + ;; "dismiss") all=0 group=0