#!/bin/bash
# 漫画资产管理器 · 一键启动（macOS / Linux）
cd "$(dirname "$0")"

if [ ! -d ".venv" ]; then
  echo "首次运行，正在创建虚拟环境…"
  if command -v python3.12 >/dev/null 2>&1; then
    python3.12 -m venv .venv
  else
    python3 -m venv .venv
  fi
  echo "安装依赖…"
  .venv/bin/pip install -q -r requirements.txt || {
    echo "官方源安装失败，改用阿里云镜像重试…";
    .venv/bin/pip install -q -i https://mirrors.aliyun.com/pypi/simple/ PySide6 "Pillow>=10";
  }
fi

exec .venv/bin/python -m comic_asset_manager.main "$@"
