nuno zrewidował ten Gist 1 month ago. Przejdź do rewizji
1 file changed, 25 insertions
gistfile1.txt(stworzono plik)
| @@ -0,0 +1,25 @@ | |||
| 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 | + | } | |
Nowsze
Starsze