print module improved

This commit is contained in:
m8in
2026-06-21 21:31:41 +02:00
parent c7b4a4a17e
commit 3ee1e22608
+30 -14
View File
@@ -23,6 +23,14 @@ function print.data() {
return 1 return 1
} }
#Function, to print done status.
function print.done() {
base.printWithColor LIGHTGREEN "(done)\n" >&2 \
&& return 0
return 1
}
#Function, for uncorrectable errors. #Function, for uncorrectable errors.
function print.error() { function print.error() {
local _MESSAGE="${@:-""}" local _MESSAGE="${@:-""}"
@@ -31,8 +39,8 @@ function print.error() {
&& base.printWithColor LIGHTRED "ERROR!\n" >&2 \ && base.printWithColor LIGHTRED "ERROR!\n" >&2 \
&& return 0 && return 0
base.printWithColor LIGHTRED "ERROR!\n" >&2 \ base.printWithColor LIGHTRED "ERROR:" >&2 \
&& base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \ && base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \
&& return 0 && return 0
return 1 return 1
@@ -48,6 +56,14 @@ function print.essential() {
return 1 return 1
} }
#Function, to print fail status.
function print.fail() {
base.printWithColor LIGHTRED "(FAIL)\n" >&2 \
&& return 0
return 1
}
#Function, for failures. #Function, for failures.
function print.failure() { function print.failure() {
[ "${1:+isset}" != "isset" ] \ [ "${1:+isset}" != "isset" ] \
@@ -121,12 +137,12 @@ function print.info() {
local _DECRIPTION="${@:-""}" local _DECRIPTION="${@:-""}"
[ -z "${_DECRIPTION:-""}" ] \ [ -z "${_DECRIPTION:-""}" ] \
&& base.printWithColor LIGHTBLUE "INFO:\n" >&2 \ && base.printWithColor LIGHTBLUE "INFO:" >&2 \
&& base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \ && base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \
&& return 0 && return 0
base.printWithColor LIGHTBLUE "INFO - " >&2 \ base.printWithColor LIGHTBLUE "INFO:" >&2 \
&& base.printWithColor WHITE "${_MESSAGE}:\n" >&2 \ && base.printWithColor WHITE " ${_MESSAGE}:\n" >&2 \
&& base.printWithColor LIGHTGREY "${_DECRIPTION}\n" >&2 \ && base.printWithColor LIGHTGREY "${_DECRIPTION}\n" >&2 \
&& return 0 && return 0
@@ -178,8 +194,8 @@ function print.success() {
&& base.printWithColor LIGHTGREEN "SUCCESS!\n" >&2 \ && base.printWithColor LIGHTGREEN "SUCCESS!\n" >&2 \
&& return 0 && return 0
base.printWithColor LIGHTGREEN "SUCCESS!\n" >&2 \ base.printWithColor LIGHTGREEN "SUCCESS:" >&2 \
&& base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \ && base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \
&& return 0 && return 0
return 1 return 1
@@ -189,11 +205,11 @@ function print.success() {
function print.tip() { function print.tip() {
local _MESSAGE="${1:?"print.tip(): Missing first parameter MESSAGE."}" local _MESSAGE="${1:?"print.tip(): Missing first parameter MESSAGE."}"
base.printWithColor CYAN "TIP:\n" >&2 base.printWithColor CYAN "TIP:" >&2 \
while [ "${_MESSAGE:-""}" != "" ]; do && base.printWithColor WHITE " ${_MESSAGE}\n" >&2
base.printWithColor LIGHTGREY " ${_MESSAGE}\n" >&2 \ while [ -n "${2}" ]; do
base.printWithColor LIGHTGREY " ${2}\n" >&2 \
&& shift \ && shift \
&& _MESSAGE="${1:-""}" \
&& continue && continue
return 1 return 1
done done
@@ -205,8 +221,8 @@ function print.tip() {
function print.warn() { function print.warn() {
local _MESSAGE="${@:?"print.warn(): Missing first parameter MESSAGE."}" local _MESSAGE="${@:?"print.warn(): Missing first parameter MESSAGE."}"
base.printWithColor YELLOW "WARNING:\n" >&2 \ base.printWithColor YELLOW "WARNING:" >&2 \
&& base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \ && base.printWithColor WHITE " ${_MESSAGE}\n" >&2 \
&& return 0 && return 0
return 1 return 1