#!/usr/bin/env bash
script_dir="$(dirname "$0")"
cd ${script_dir}

. imports.sh

OPTION_PROPAGATE=1

help_message


if [[ -e ${PSALM_CONFIG} ]]
then
  comment "Psalm config found..."
else
  comment "Creating psalm config..."
  if [[ ${EXEC} == 1  ]]
    then
      docker-compose -f ${DOCKER_COMPOSE_FILE} exec app psalm --init ${SOURCE_DIR} ${PSALM_LEVEL}
    else
      no-exec
  fi
fi

info "Psalm..."
docker-compose -f ${DOCKER_COMPOSE_FILE} exec app psalm --version
if [[ ${EXEC} == 1 ]]
then
    if [[ -z "$@" ]]
    then
        docker-compose -f ${DOCKER_COMPOSE_FILE} exec app psalm
    else
        docker-compose -f ${DOCKER_COMPOSE_FILE} exec app psalm "$@"
    fi
else
  no-exec
fi

