Naposledy aktivní 1 month ago

Revize 6e74607d44c8922ca0203e33f65d2fd10853978c

gistfile1.txt Raw
1function cmd::list::_render_summary() {
2 local group_summary="${1:-}"
3 local -n _rule_counts="$2"
4 local total="${3:-}" # filtered total
5
6 # total=$(find "$(ctx::clients)" -name "*.conf" | wc -l | tr -d ' ')
7
8 # Count total from rule_counts (only filtered peers)
9 local total=0
10 for r in "${!_rule_counts[@]}"; do
11 (( total += _rule_counts[$r] )) || true
12 done
13
14 local summary=""
15 for r in "${!_rule_counts[@]}"; do
16 summary+="${_rule_counts[$r]} ${r}, "
17 done
18 summary="${summary%, }"
19
20 if [[ -n "$group_summary" ]]; then
21 printf "\n Showing %s peers [%s] — %s\n\n" "$total" "$summary" "$group_summary"
22 else
23 printf "\n Showing %s peers [%s]\n\n" "$total" "$summary"
24 fi
25}