#!/bin/bash
# omarchy:summary=List China app catalog entries and their sources
# omarchy:examples=omarchycn app list

set -euo pipefail

APPS_JSON="$OMARCHY_PATH/cn/apps.json"

printf '%-14s %-10s %-8s %-12s %s\n' "ID" "NAME" "SOURCE" "LICENSE" "PACKAGE/URL"
jq -r '.apps | to_entries[] |
  [.key, .value.name, .value.source, .value.license, (.value.package // .value.url)] | @tsv' \
  "$APPS_JSON" |
  while IFS=$'\t' read -r id name source license ref; do
    printf '%-14s %-10s %-8s %-12s %s\n' "$id" "$name" "$source" "$license" "$ref"
  done
