#!/bin/bash
# Santa Package Manager Check Script
# Generated: {{ timestamp }}
# Version: {{ version }}
# Source: {{ source_name }}
# Manager: {{ manager }}

set -euo pipefail

echo "🎅 Santa Package Check - {{ source_name }}"
echo "Generated: {{ timestamp }}"
echo "Manager: {{ manager }}"
echo ""

{% if manager == "brew" %}
# Homebrew package check
if command -v brew &> /dev/null; then
    echo "📦 Checking Homebrew packages..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  Homebrew not found."
    exit 1
fi

{% elif manager == "apt" or manager == "apt-get" %}
# APT package check
if command -v apt &> /dev/null; then
    echo "📦 Checking APT packages..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  APT not found."
    exit 1
fi

{% elif manager == "yum" %}
# YUM package check
if command -v yum &> /dev/null; then
    echo "📦 Checking YUM packages..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  YUM not found."
    exit 1
fi

{% elif manager == "pacman" %}
# Pacman package check
if command -v pacman &> /dev/null; then
    echo "📦 Checking Pacman packages..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  Pacman not found."
    exit 1
fi

{% elif manager == "npm" %}
# NPM package check
if command -v npm &> /dev/null; then
    echo "📦 Checking NPM packages..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  NPM not found."
    exit 1
fi

{% elif manager == "pip" or manager == "pip3" %}
# Python pip package check
if command -v {{ manager }} &> /dev/null; then
    echo "📦 Checking Python packages with {{ manager }}..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  {{ manager }} not found."
    exit 1
fi

{% elif manager == "cargo" %}
# Rust cargo package check
if command -v cargo &> /dev/null; then
    echo "📦 Checking Rust packages..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  Cargo not found."
    exit 1
fi

{% elif manager == "go" %}
# Go package check
if command -v go &> /dev/null; then
    echo "📦 Checking Go packages..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  Go not found."
    exit 1
fi

{% else %}
# Generic package manager check
if command -v {{ manager }} &> /dev/null; then
    echo "📦 Checking packages with {{ manager }}..."
    {{ check_command | shell_escape }}
else
    echo "⚠️  {{ manager }} not found."
    exit 1
fi
{% endif %}

echo ""
echo "Generated by Santa v{{ version }} - https://github.com/tylerbutler/santa"