gistfile1.txt
· 2.4 KiB · Text
Неформатований
#!/usr/bin/env bash
# ui/identity.module.sh — rendering for identity data
# All functions pure rendering — no writes, no state changes.
function ui::identity::header() {
printf " %-20s %-7s %s\n" "IDENTITY" "PEERS" "DEVICE TYPES"
ui::divider 54
}
function ui::identity::row() {
local name="${1:-}" peer_count="${2:-}" types="${3:-}"
local types_display="${types//,/, }"
[[ -z "$types_display" ]] && types_display="—"
printf " %-20s %-7s %s\n" "$name" "$peer_count" "$types_display"
}
function ui::identity::detail_name() {
local name="${1:-}" peer_count="${2:-}"
echo ""
ui::row "Identity" "$name"
ui::row "Peers" "$peer_count"
echo ""
}
function ui::identity::device_row() {
local peer_name="${1:-}" dev_type="${2:-}" \
dev_index="${3:-1}" status="${4:-}"
local suffix=""
[[ "$dev_index" -gt 1 ]] && suffix=" (#${dev_index})"
printf " · %-24s %-10s%s%s\n" \
"$peer_name" "$dev_type" "$suffix" "$status"
}
function ui::identity::migrate_create() {
local peer_name="${1:-}" identity_name="${2:-}" \
peer_type="${3:-}" index="${4:-}"
printf " %s %-22s → identity %-14s %-10s #%s\n" \
"$(color::green "+")" "$peer_name" "$identity_name" "$peer_type" "$index"
}
function ui::identity::migrate_skip() {
local peer_name="${1:-}"
printf " %s %-22s (no convention match)\n" \
"$(color::dim "·")" "$peer_name"
}
function ui::identity::migrate_summary() {
local created="${1:-0}" skipped="${2:-0}" dry_run="${3:-false}"
echo ""
if [[ "$dry_run" == "true" ]]; then
log::info "Would create entries for ${created} peers (${skipped} skipped)"
else
log::ok "Created identity entries for ${created} peers (${skipped} skipped)"
fi
}
function ui::identity::list_row_compact() {
local name="${1:-}" peer_count="${2:-}" rules_list="${3:-}" policy="${4:-}"
local peer_word="peers"
[[ "$peer_count" -eq 1 ]] && peer_word="peer"
local peers_col="${peer_count} ${peer_word}"
local rules_col=""
[[ -n "$rules_list" ]] && rules_col="rules: ${rules_list}"
printf " \033[1m%-20s\033[0m %-10s %-34s \033[2mpolicy:\033[0m %s\n" \
"$name" "$peers_col" "$rules_col" "$policy"
}
Piden
function ui::identity::list_row_table() {
local name="${1:-}" peer_count="${2:-}" types="${3:-}"
local types_display="${types//,/, }"
[[ -z "$types_display" ]] && types_display="—"
printf " %-20s %-7s %s\n" "$name" "$peer_count" "$types_display"
}
| 1 | #!/usr/bin/env bash |
| 2 | # ui/identity.module.sh — rendering for identity data |
| 3 | # All functions pure rendering — no writes, no state changes. |
| 4 | |
| 5 | function ui::identity::header() { |
| 6 | printf " %-20s %-7s %s\n" "IDENTITY" "PEERS" "DEVICE TYPES" |
| 7 | ui::divider 54 |
| 8 | } |
| 9 | |
| 10 | function ui::identity::row() { |
| 11 | local name="${1:-}" peer_count="${2:-}" types="${3:-}" |
| 12 | local types_display="${types//,/, }" |
| 13 | [[ -z "$types_display" ]] && types_display="—" |
| 14 | printf " %-20s %-7s %s\n" "$name" "$peer_count" "$types_display" |
| 15 | } |
| 16 | |
| 17 | function ui::identity::detail_name() { |
| 18 | local name="${1:-}" peer_count="${2:-}" |
| 19 | echo "" |
| 20 | ui::row "Identity" "$name" |
| 21 | ui::row "Peers" "$peer_count" |
| 22 | echo "" |
| 23 | } |
| 24 | |
| 25 | function ui::identity::device_row() { |
| 26 | local peer_name="${1:-}" dev_type="${2:-}" \ |
| 27 | dev_index="${3:-1}" status="${4:-}" |
| 28 | local suffix="" |
| 29 | [[ "$dev_index" -gt 1 ]] && suffix=" (#${dev_index})" |
| 30 | printf " · %-24s %-10s%s%s\n" \ |
| 31 | "$peer_name" "$dev_type" "$suffix" "$status" |
| 32 | } |
| 33 | |
| 34 | function ui::identity::migrate_create() { |
| 35 | local peer_name="${1:-}" identity_name="${2:-}" \ |
| 36 | peer_type="${3:-}" index="${4:-}" |
| 37 | printf " %s %-22s → identity %-14s %-10s #%s\n" \ |
| 38 | "$(color::green "+")" "$peer_name" "$identity_name" "$peer_type" "$index" |
| 39 | } |
| 40 | |
| 41 | function ui::identity::migrate_skip() { |
| 42 | local peer_name="${1:-}" |
| 43 | printf " %s %-22s (no convention match)\n" \ |
| 44 | "$(color::dim "·")" "$peer_name" |
| 45 | } |
| 46 | |
| 47 | function ui::identity::migrate_summary() { |
| 48 | local created="${1:-0}" skipped="${2:-0}" dry_run="${3:-false}" |
| 49 | echo "" |
| 50 | if [[ "$dry_run" == "true" ]]; then |
| 51 | log::info "Would create entries for ${created} peers (${skipped} skipped)" |
| 52 | else |
| 53 | log::ok "Created identity entries for ${created} peers (${skipped} skipped)" |
| 54 | fi |
| 55 | } |
| 56 | |
| 57 | function ui::identity::list_row_compact() { |
| 58 | local name="${1:-}" peer_count="${2:-}" rules_list="${3:-}" policy="${4:-}" |
| 59 | local peer_word="peers" |
| 60 | [[ "$peer_count" -eq 1 ]] && peer_word="peer" |
| 61 | |
| 62 | local peers_col="${peer_count} ${peer_word}" |
| 63 | local rules_col="" |
| 64 | [[ -n "$rules_list" ]] && rules_col="rules: ${rules_list}" |
| 65 | |
| 66 | printf " \033[1m%-20s\033[0m %-10s %-34s \033[2mpolicy:\033[0m %s\n" \ |
| 67 | "$name" "$peers_col" "$rules_col" "$policy" |
| 68 | } |
| 69 | Piden |
| 70 | function ui::identity::list_row_table() { |
| 71 | local name="${1:-}" peer_count="${2:-}" types="${3:-}" |
| 72 | local types_display="${types//,/, }" |
| 73 | [[ -z "$types_display" ]] && types_display="—" |
| 74 | printf " %-20s %-7s %s\n" "$name" "$peer_count" "$types_display" |
| 75 | } |