#!/usr/bin/env bash

/usr/bin/mkinitcpio "$@"

_color_reset=""
_color_yellow=""
colors="$(tput colors 2>/dev/null || echo 0)"
if ((colors >= 8)); then
	_color_reset="\033[0m"
	_color_yellow="\033[1;33m"
fi

if [[ " $* " == *" -P "* || " $* " == *" --allpresets "* || " $* " == *" -p "* || " $* " == *" --preset "* ]]; then
	echo -e "${_color_yellow}==> WARNING: This does not update Limine boot entries.${_color_reset}" >&2
	echo -e "${_color_yellow}    Use 'limine-mkinitcpio' or 'limine-update' instead.${_color_reset}" >&2

	read -rp "==> Would you like to run 'limine-mkinitcpio' now? [Y/n]: " answer
	case "${answer,,}" in
	"" | "y" | "yes")
		/usr/bin/limine-mkinitcpio
		;;
	*)
		# nothing
		;;
	esac
fi
