#!/bin/bash
#########################################################
# 							#
# This is BashStyle-NG  				#
#							#
# Licensed under GNU GENERAL PUBLIC LICENSE v3    	#
#							#
# Copyright 2007 - 2017 Christopher Bratusek		#
#							#
#########################################################

section_message () {

	case ${1} in
		APP )		echo -e "\n${RED}< Required ${WHITE}Applications" ;;
		OPT_APP )	echo -e "\n${MAGENTA}< Optional ${WHITE}Applications" ;;
		SBINAPP )	echo -e "\n${RED}< Required ${WHITE}SuperUser Applications" ;;
		OPT_SBINAPP )	echo -e "\n${MAGENTA}< Optional ${WHITE}SuperUser Applications" ;;
		BUILD )		echo -e "\n${RED}< Required ${WHITE}Build Tools" ;;
		PY )		echo -e "\n${RED}< Python Interpreter${WHITE} > ${PYMINVER_P} && < ${PYMAXVER_P}" ;;
		PYMOD )		echo -e "\n${RED}< Required ${WHITE}Python Modules" ;;
		OPT_PYMOD )	echo -e "\n${MAGENTA}< Optional ${WHITE}Python Modules" ;;
		LIB )		echo -e "\n${RED}< Required ${WHITE}Libraries" ;;
		OPT_LIB )	echo -e "\n${MAGENTA}< Optional ${WHITE}Libraries" ;;
		GIR )		echo -e "\n${RED}< Required ${WHITE}GIR Repositories" ;;
		OPT_GIR)	echo -e "\n${MAGENTA}< Optional ${WHITE}GIR Repositories" ;;
	esac
	tput sgr0

}

start_message () {

	echo -e "\n${WHITE}Configuring ${GREEN}${APP_NAME}${YELLOW} v${APP_VERSION} ${CYAN}(${APP_CODENAME})"
	tput sgr0

}

ok_message () {

	if [[ ${2} != "" ]]; then
		echo -e "${WHITE}\t+ ${CYAN}${1}${MAGENTA} >${GREEN} OK${SILVER} ( ${2} )"
	else	echo -e "${WHITE}\t+ ${CYAN}${1}${MAGENTA} >${GREEN} OK"
	fi
	tput sgr0
}

fail_message () {

	case ${1} in
		m )	echo -e "${WHITE}\t+ ${CYAN}${2}${MAGENTA} >${RED} !MISSING!" ;;
		o )	echo -e "${WHITE}\t+ ${CYAN}${2}${MAGENTA} >${RED} !OLDER THAN ${3}!" ;;
		p )	echo -e "${WHITE}\t+ ${CYAN}Python ($PYTHON)${MAGENTA} >${RED} !MISSING!" ;;
		p- )	echo -e "${WHITE}\t+ ${CYAN}Python ($PYTHON)${MAGENTA} >${RED} !OLDER THAN ${PYMINVER_P}!" ;;
		p+ )	echo -e "${WHITE}\t+ ${CYAN}Python ($PYTHON)${MAGENTA} >${RED} !IS ${PYMAXVER_P} OR ABOVE!" ;;
	esac
	tput sgr0

}

warn_message () {

	echo -e "${WHITE}\t+ ${CYAN}${1}${MAGENTA} >${YELLOW} Not Available\
		\n\t  > ${WHITE}${2}"
	tput sgr0

}

maintainer_message () {

	echo -e "\n${RED}Maintainer Mode ${WHITE}/ ${GREEN}Disabled Checks"
	tput sgr0

}

end_message () {

	export PATH="$OLDPATH"
	echo -e "\n${BLUE}Notes from configure:\
		 \n${YELLOW}Prefix\t\t\t${WHITE}>${MAGENTA} ${PREFIX}\
		 \n${YELLOW}Python\t\t\t${WHITE}>${MAGENTA} ${PYTHON}"
	if [[ ${DISABLE_POSTINSTALL} ]]; then
		echo -e "${YELLOW}Post-Install Tasks\t${WHITE}>${RED} Disabled"
	else	echo -e "${YELLOW}Post-Install Tasks\t${WHITE}>${GREEN} Enabled"
	fi
	echo -e "\n\t${WHITE}You may want to continue with './make build'.\n"
	tput sgr0

}

help_message () {

	echo -e "\n${GREEN}${APP_NAME} ${MAGENTA}v${APP_VERSION}${WHITE} / ${YELLOW}Configure v${CFG_VERSION} ${CYAN}help
	\n${WHITE}Options:"

	echo -e "	${ORANGE}--help${WHITE} *|${GREEN} Display this help message
	${ORANGE}--prefix=<prefix>${WHITE} *|${GREEN} Change installation prefix (default: /usr)
	${ORANGE}--bindir=<bindir>${WHITE} *|${GREEN} Change binary path (default: /usr/bin)
	${ORANGE}--docdir=<docdir>${WHITE} *|${GREEN} Change doc path (default: /usr/share/doc/)
	${ORANGE}--mandir=<mandir>${WHITE} *|${GREEN} Change man path (default: /usr/share/man/)
	${ORANGE}--datadir=<datadir>${WHITE} *|${GREEN} Change data path (default: /usr/share/)
	${ORANGE}--pcdir=<pcdir>${WHITE} *|${GREEN} Change pkg-config path (default: /usr/share/pkgconfig)
	${ORANGE}--girpath=<girpath>${WHITE} *|${GREEN} Where to look for G-I typelibs (default: /usr/lib/girepository-1.0/)
	${ORANGE}--python=<python>${WHITE} *|${GREEN} Make BashStyle-NG use a specific python (default: /usr/bin/python)
	${ORANGE}--no-postinstall${WHITE} *|${GREEN} Disable post-installation tasks (for package-maintainers) " | column -t -s \*
	tput sgr0

}

missing_girpath_message () {

	echo -e "${RED}*** GIRPATH not detected ***${WHITE}
	configure --girpath=<girpath> to specify where to look for
	gobject-introspection files\n"
	tput sgr0

}
