gistfile1.txt
· 706 B · Text
Surowy
function cmd::list::_render_summary() {
local group_summary="${1:-}"
local -n _rule_counts="$2"
local total="${3:-}" # filtered total
# total=$(find "$(ctx::clients)" -name "*.conf" | wc -l | tr -d ' ')
# Count total from rule_counts (only filtered peers)
local total=0
for r in "${!_rule_counts[@]}"; do
(( total += _rule_counts[$r] )) || true
done
local summary=""
for r in "${!_rule_counts[@]}"; do
summary+="${_rule_counts[$r]} ${r}, "
done
summary="${summary%, }"
if [[ -n "$group_summary" ]]; then
printf "\n Showing %s peers [%s] — %s\n\n" "$total" "$summary" "$group_summary"
else
printf "\n Showing %s peers [%s]\n\n" "$total" "$summary"
fi
}
| 1 | function 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 | } |