#!/usr/bin/env sh
set -eu

target="${1:-}"

if [ -z "${DISABLE_WARN_OUTSIDE_CONTAINER:-}" ]; then
		case $target in
			clean|dev|help|shell)
				# no warning needed for these targets
				;;
			*)
				(
						printf "\n"
						printf "\033[1mWARNING\033[0m: you are not in a container.\n"
						printf "\n"
						printf 'Use "\033[1mmake dev\033[0m" to start an interactive development container,\n'
						printf 'use "\033[1mmake -f docker.Makefile %s\033[0m" to execute this target\n' "$target"
						printf "in a container, or set \033[1mDISABLE_WARN_OUTSIDE_CONTAINER=1\033[0m to\n"
						printf "disable this warning.\n"
						printf "\n"
						printf "Press \033[1mCtrl+C\033[0m now to abort, or wait for the script to continue..\n"
				) >&2
				sleep 5
				;;
		esac
fi
