fix: list_outline_collections.sh - correct jq parsing to output valid JSON array
This commit is contained in:
32
skills/doc-translator/scripts/list_outline_collections.sh
Executable file
32
skills/doc-translator/scripts/list_outline_collections.sh
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# List all collections available in Outline
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# list_outline_collections.sh
|
||||||
|
#
|
||||||
|
# Environment:
|
||||||
|
# OUTLINE_API_KEY - Bearer token for wiki.az-gruppe.com API
|
||||||
|
#
|
||||||
|
# Output (JSON):
|
||||||
|
# [{"id": "...", "name": "...", "url": "..."}, ...]
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# List collections
|
||||||
|
RESPONSE=$(curl -s -X POST "https://wiki.az-gruppe.com/api/collections.list" \
|
||||||
|
-H "Authorization: Bearer $OUTLINE_API_KEY" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{}')
|
||||||
|
|
||||||
|
# Check for errors
|
||||||
|
if echo "$RESPONSE" | jq -e '.error' > /dev/null 2>&1; then
|
||||||
|
ERROR_MSG=$(echo "$RESPONSE" | jq -r '.message // "Failed to list collections"')
|
||||||
|
echo "{\"success\": false, \"error\": \"$ERROR_MSG\", \"response\": \"$RESPONSE\"}" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract collection list
|
||||||
|
COLLECTIONS=$(echo "$RESPONSE" | jq -r '.data[] | {id: .id, name: .name, url: .url}')
|
||||||
|
|
||||||
|
# Output as JSON array
|
||||||
|
echo "$COLLECTIONS" | jq -s '.'
|
||||||
Reference in New Issue
Block a user