#!/bin/sh
# narOS introspection CLI (NAROS.md §6.3). Reads /etc/naros + /etc/os-release only.
set -eu
MANIFEST=/etc/naros/manifest.json

case "${1:-info}" in
  version)
    . /etc/os-release
    echo "narOS ${VERSION_ID:-unknown} (${VARIANT:-?}/$(cat /etc/naros/channel 2>/dev/null || echo '?'))"
    ;;
  info)
    if [ "${2:-}" = "--json" ]; then
      cat "$MANIFEST"
    elif command -v jq > /dev/null 2>&1; then
      jq . "$MANIFEST"
    else
      cat "$MANIFEST"
    fi
    ;;
  *)
    echo "usage: naros [info [--json] | version]" >&2
    exit 2
    ;;
esac
