#!/usr/bin/env bash

set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_ROOT"
source "$REPO_ROOT/scripts/version-common.sh"

APP_VERSION="$(smplayer_current_version macos)"
echo "[dev-macos] App version: $APP_VERSION (windows/pc line)"

RUN_ARGS=(run -d macos)
if [[ $# -gt 0 ]]; then
  RUN_ARGS+=("$@")
fi
if ! smplayer_has_dart_define SMPLAYER_VERSION "${RUN_ARGS[@]}"; then
  RUN_ARGS+=("--dart-define=SMPLAYER_VERSION=$APP_VERSION")
fi

echo "[dev-macos] flutter ${RUN_ARGS[*]}"
exec flutter "${RUN_ARGS[@]}"
