Última atividade 1 month ago

nuno revisou este gist 1 month ago. Ir para a revisão

1 file changed, 51 insertions

gistfile1.txt(arquivo criado)

@@ -0,0 +1,51 @@
1 + #!/usr/bin/env bash
2 + # ui/subnet.module.sh — rendering for subnet data
3 + # All functions pure rendering — no writes, no state changes.
4 +
5 + function ui::subnet::header() {
6 + printf " %-14s %-18s %-10s %-8s %s\n" \
7 + "NAME" "SUBNET" "TYPE" "TUNNEL" "DESCRIPTION"
8 + ui::divider 70
9 + }
10 +
11 + function ui::subnet::row() {
12 + local display_name="${1:-}" subnet="${2:-}" type_key="${3:-}" \
13 + tunnel_mode="${4:-}" desc="${5:-}" is_group="${6:-false}"
14 + local name_col="$display_name"
15 + [[ "$is_group" == "true" ]] && name_col=" ${display_name}"
16 + printf " %-14s %-18s %-10s %-8s %s\n" \
17 + "$name_col" "$subnet" "$type_key" "$tunnel_mode" "$desc"
18 + }
19 +
20 + function ui::subnet::group_separator() {
21 + echo ""
22 + }
23 +
24 + function ui::subnet::detail() {
25 + local name="${1:-}" is_group="${2:-false}"
26 + ui::row "Name" "$name"
27 + ui::row "Type" "$( [[ "$is_group" == "true" ]] && echo "group" || echo "scalar" )"
28 + }
29 +
30 + function ui::subnet::detail_field() {
31 + local key="${1:-}" value="${2:-}"
32 + ui::row "$key" "$value"
33 + }
34 +
35 + function ui::subnet::child_header() {
36 + printf "\n"
37 + printf " %-12s %-18s %-8s %s\n" "TYPE" "SUBNET" "TUNNEL" "DESCRIPTION"
38 + ui::divider 56
39 + }
40 +
41 + function ui::subnet::child_row() {
42 + local type_key="${1:-}" subnet="${2:-}" tunnel_mode="${3:-}" desc="${4:-}"
43 + printf " %-12s %-18s %-8s %s\n" "$type_key" "$subnet" "$tunnel_mode" "$desc"
44 + }
45 +
46 + function ui::subnet::peers_in_use() {
47 + local peers_csv="${1:-}"
48 + [[ -z "$peers_csv" ]] && return 0
49 + echo ""
50 + ui::row "Peers using" "${peers_csv//,/, }"
51 + }
Próximo Anterior