Add colour printing

This commit is contained in:
LinuxSquare 2025-04-25 21:21:33 +02:00
parent 22d663e8ac
commit 37c31d3ce6
2 changed files with 33 additions and 6 deletions

View file

@ -17,13 +17,13 @@ function check_remote() {
function check_local() {
if [[ $(get_current_novos_version) < $(get_cached_novos_version) ]]; then
if ! test -f "$RUN_DIR/quiet"; then
cat<<EOF
There is a newer NOVOS version available: $(get_cached_novos_version)
You are currently running NOVOS $(get_current_novos_version)!
To upgrade to this version, execute: 'nsm sysupgrade'
This message will vanish if you upgrade or type 'nsm check quiet' for some reason.
EOF
printc "y" "There is a newer NOVOS version available: $(get_cached_novos_version)"
printc "y" "You are currently running NOVOS $(get_current_novos_version)!"
echo ""
printc "y" "To upgrade to this version, execute: 'nsm sysupgrade'"
printc "y" "This message will vanish if you upgrade or type 'nsm check quiet' for some reason."
fi
return 1
else

View file

@ -53,3 +53,30 @@ function log() {
"${print}" && echo -e "${prefix} ${message}"
return 0
}
function printc() {
colour="${1}"
shift
message=$@
case "${colour}" in
"g")
echo -ne "${GREEN}${message}${RESET}\n"
;;
"m")
echo -ne "${MAGENTA}${message}${RESET}\n"
;;
"b")
echo -ne "${BLUE}${message}${RESET}\n"
;;
"y")
echo -ne "${YELLOW}${message}${RESET}\n"
;;
"r")
echo -ne "${RED}${message}${RESET}\n"
;;
*)
log e "There is no such colour available!"
exit 1
;;
esac
}