#!/usr/bin/env bash
# Aria-Skill-Cookiecutter Init-Script
# Replaces template placeholders in current dir.
set -euo pipefail
SKILL_NAME="${1:?usage: init.sh <skill-name> <description>}"
SKILL_DESC="${2:?usage: init.sh <skill-name> <description>}"
SKILL_TITLE="$(echo "$SKILL_NAME" | sed 's/-/ /g; s/.*/\u&/')"
CREATED_DATE="$(date -u +%Y-%m-%d)"
AUTHOR="${AUTHOR:-aria}"

if [[ -f SKILL.md.template ]]; then
  sed -e "s|{{SKILL_NAME}}|$SKILL_NAME|g" \
      -e "s|{{SKILL_DESCRIPTION}}|$SKILL_DESC|g" \
      -e "s|{{SKILL_TITLE}}|$SKILL_TITLE|g" \
      -e "s|{{SKILL_TAGLINE}}|$SKILL_DESC|g" \
      -e "s|{{CREATED_DATE}}|$CREATED_DATE|g" \
      -e "s|{{LINKED_KAR}}|TBD|g" \
      -e "s|{{AUTHOR}}|$AUTHOR|g" \
      -e "s|{{TRIGGER_CONDITIONS}}|TODO: when to trigger|g" \
      -e "s|{{WORKFLOW_STEPS}}|TODO: 1. step|g" \
      -e "s|{{RELATED_REFERENCES}}|TODO: links|g" \
      SKILL.md.template > SKILL.md
  rm SKILL.md.template
  echo "OK: SKILL.md generated for $SKILL_NAME"
fi
