#!/bin/sh
#
# jrnl-tag - find terms in jrnl files, turn them into tags
# check with `jrnl --tags`

if test "$#" -eq 0; then
  "$0" sleep nap tech read dev phone run laptop computer PC journal wiki
else
  # TODO(2025-09-20): rpl?
  for arg in "${@-}"; do
    rpl "\(^\|[^@]\)\b${arg}\b" "\1@${arg}" "${JOURNAL:-}"/*.jrnl 2>/dev/null
    rpl "\(^\|[^@]\)\b${arg}\b" "\1@${arg}" "${JOURNAL:-}"/*.txt 2>/dev/null
  done
fi
