#!/usr/bin/env bash
# where — locate a thread's declaration. Short, directly-invokable wrapper:
#   where <thread>     # site / file / line of the thread's protocol block
# Maps to: nc-find.sh --where <thread> (v1 `<thread> where`).
set -o pipefail
_self="${BASH_SOURCE[0]}"; [ -L "$_self" ] && _self="$(readlink "$_self")"
. "$(cd "$(dirname "$_self")" && pwd)/_nc_common.sh"

if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
  awk 'NR==1{next} /^#/{sub(/^# ?/,""); print; next} {exit}' "${BASH_SOURCE[0]}"
  exit 0
fi
[ $# -ge 1 ] || { echo "where: usage: where <thread>" >&2; exit 2; }

lib="$(_nc_resolve_lib)" || { echo "where: lib/ toolkit not found (set LARRY_LIB_DIR or LARRY_HOME)" >&2; exit 1; }
thr="$1"; shift
exec bash "$lib/nc-find.sh" --where "$thr" "$@"
