65 lines
2.0 KiB
Bash
Executable File
65 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# okf-gen-graph.sh — Gera grafo OKF do Hub para integração com Wayland/visualização
|
|
#
|
|
# Uso:
|
|
# bash scripts/okf-gen-graph.sh → gera hub-okf-graph.dot
|
|
# bash scripts/okf-gen-graph.sh --svg → gera também hub-okf-graph.svg (requer graphviz)
|
|
# bash scripts/okf-gen-graph.sh --info → mostra inventário do bundle
|
|
#
|
|
# Requer: okf CLI (cargo install --git https://github.com/W4G1/okf)
|
|
#
|
|
# Criado: 28-06-2026
|
|
|
|
set -euo pipefail
|
|
|
|
VAULT="/media/ealmeida/Dados/Hub"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
OUTPUT_DOT="$SCRIPT_DIR/hub-okf-graph.dot"
|
|
|
|
BLUE='\033[0;34m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
info() { echo -e "${BLUE}[INFO]${NC} $*"; }
|
|
ok() { echo -e "${GREEN}[OK]${NC} $*"; }
|
|
warn() { echo -e "${YELLOW}[AVISO]${NC} $*"; }
|
|
|
|
if ! command -v okf &>/dev/null; then
|
|
echo -e "${RED}[ERRO]${NC} okf CLI não encontrado."
|
|
echo " Instalar: cargo install --git https://github.com/W4G1/okf"
|
|
echo " Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
|
|
exit 1
|
|
fi
|
|
|
|
# Inventário do bundle
|
|
if [[ "${1:-}" == "--info" ]]; then
|
|
info "=== OKF Bundle Inventory ==="
|
|
okf info "$VAULT" 2>/dev/null
|
|
exit 0
|
|
fi
|
|
|
|
# Gerar grafo DOT
|
|
info "A gerar grafo OKF do Hub..."
|
|
okf graph "$VAULT" --dot 2>/dev/null > "$OUTPUT_DOT"
|
|
NODE_COUNT=$(grep -c "^ " "$OUTPUT_DOT" 2>/dev/null || echo "?")
|
|
ok "Grafo gerado: $OUTPUT_DOT ($NODE_COUNT nós/arestas)"
|
|
|
|
# Gerar SVG se graphviz disponível e --svg pedido
|
|
if [[ "${1:-}" == "--svg" ]]; then
|
|
OUTPUT_SVG="${OUTPUT_DOT%.dot}.svg"
|
|
if command -v dot &>/dev/null; then
|
|
info "A gerar SVG via graphviz..."
|
|
dot -Tsvg "$OUTPUT_DOT" -o "$OUTPUT_SVG" 2>/dev/null
|
|
ok "SVG gerado: $OUTPUT_SVG"
|
|
info "Abrir com: xdg-open $OUTPUT_SVG"
|
|
else
|
|
warn "graphviz não instalado — só o DOT foi gerado"
|
|
warn "Instalar: sudo apt install graphviz"
|
|
warn "Ou visualizar online: https://dreampuf.github.io/GraphvizOnline/"
|
|
fi
|
|
fi
|
|
|
|
info "Para Wayland F6: usar $OUTPUT_DOT como input de importação da estrutura Hub"
|