Merge pull request #68 from outis1one/claude/zealous-feynman-odDrh

tools: fix fbq-add-source.sh failing to list sources with inline yaml…
This commit is contained in:
Outis
2026-06-08 08:39:46 -04:00
committed by GitHub
+8 -2
View File
@@ -107,13 +107,16 @@ backup() {
# ── Check if a source path already exists in config ──────────────────────────
source_exists() {
local config="$1" path="$2"
yq e '.server.sources[].path' "$config" 2>/dev/null | grep -qxF "$path"
sed 's/[[:space:]]*#.*$//' "$config" \
| yq e '.server.sources[].path' - 2>/dev/null \
| grep -qxF "$path"
}
# ── List existing sources ─────────────────────────────────────────────────────
list_sources() {
local config="$1"
yq e '.server.sources[] | .path' "$config" 2>/dev/null
# Strip inline comments before parsing — yq can mishandle them mid-array
sed 's/[[:space:]]*#.*$//' "$config" | yq e '.server.sources[] | .path' - 2>/dev/null
}
# ── Restart the container ─────────────────────────────────────────────────────
@@ -179,6 +182,9 @@ cmd_add() {
[[ "${read_only_bool_raw,,}" == "y" ]] && read_only_bool="true"
backup "$config"
# Strip inline comments first so yq edits cleanly
local tmp; tmp=$(mktemp)
sed 's/[[:space:]]*#.*$//' "$config" > "$tmp" && mv "$tmp" "$config"
yq e -i ".server.sources += [{
\"path\": \"${container_path}\",
\"name\": \"${source_name}\",