#!/bin/sh
# Stub steamcmd binary for testing.
# Parses +force_install_dir and +workshop_download_item args.
# Creates fake mod directories and prints fake download logs.

INSTALL_DIR=""
MOD_IDS=""

while [ $# -gt 0 ]; do
  case "$1" in
    +force_install_dir) INSTALL_DIR="$2"; shift 2 ;;
    +workshop_download_item)
      APP_ID="$2"; MOD_ID="$3"; shift 3
      MOD_IDS="$MOD_IDS $MOD_ID"
      ;;
    *) shift ;;
  esac
done

echo "[STUB] steamcmd install_dir=$INSTALL_DIR mods=$MOD_IDS"

for MOD_ID in $MOD_IDS; do
  MOD_DIR="$INSTALL_DIR/steamapps/workshop/content/107410/$MOD_ID"
  echo "[STUB] Downloading item $MOD_ID (App $APP_ID)..."
  echo "[STUB] Downloading 100% [//////////]"
  mkdir -p "$MOD_DIR"
  echo "[STUB] Success! App $APP_ID item $MOD_ID installed to $MOD_DIR"
done

echo "[STUB] steamcmd exiting"
exit 0
