summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
Diffstat (limited to 'functions')
-rwxr-xr-xfunctions/color.sh41
-rwxr-xr-xfunctions/defaults.sh1
-rwxr-xr-xfunctions/echo.sh173
3 files changed, 173 insertions, 42 deletions
diff --git a/functions/color.sh b/functions/color.sh
index feac48b..03d333c 100755
--- a/functions/color.sh
+++ b/functions/color.sh
@@ -7,34 +7,31 @@
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.
-if [ "${LH_COLOR}" != "disabled" ]
-then
- NO_COLOR="\033[0m"
+NO_COLOR="\033[0m"
- UNDERSCORE="\033[4m"
- BLINK="\033[5m"
+UNDERSCORE="\033[4m"
+BLINK="\033[5m"
- BLACK="\033[0;30m"
- DARK_GRAY="\033[1;30m"
+BLACK="\033[0;30m"
+DARK_GRAY="\033[1;30m"
- RED="\033[0;31m"
- LIGHT_RED="\033[1;31m"
+RED="\033[0;31m"
+LIGHT_RED="\033[1;31m"
- GREEN="\033[0;32m"
- LIGHT_GREEN="\033[1;32m"
+GREEN="\033[0;32m"
+LIGHT_GREEN="\033[1;32m"
- BROWN="\033[0;33m"
- YELLOW="\033[1;33m"
+BROWN="\033[0;33m"
+YELLOW="\033[1;33m"
- BLUE="\033[0;34m"
- LIGHT_BLUE="\033[1;34m"
+BLUE="\033[0;34m"
+LIGHT_BLUE="\033[1;34m"
- PURPLE="\033[0;35m"
- LIGHT_PURPLE="\033[1;35m"
+PURPLE="\033[0;35m"
+LIGHT_PURPLE="\033[1;35m"
- CYAN="\033[0;36m"
- LIGHT_CYAN="\033[1;36m"
+CYAN="\033[0;36m"
+LIGHT_CYAN="\033[1;36m"
- GRAY="\033[0;37m"
- WHITE="\033[1;37m"
-fi
+GRAY="\033[0;37m"
+WHITE="\033[1;37m"
diff --git a/functions/defaults.sh b/functions/defaults.sh
index 4592d21..3636c21 100755
--- a/functions/defaults.sh
+++ b/functions/defaults.sh
@@ -221,6 +221,7 @@ Set_defaults ()
# Setting live helper options
_BREAKPOINTS="${_BREAKPOINTS:-disabled}"
+ _COLOR="${_COLOR:-disabled}"
_DEBUG="${_DEBUG:-disabled}"
_FORCE="${_FORCE:-disabled}"
_QUIET="${_QUIET:-disabled}"
diff --git a/functions/echo.sh b/functions/echo.sh
index 8162212..e578723 100755
--- a/functions/echo.sh
+++ b/functions/echo.sh
@@ -22,11 +22,11 @@ Echo ()
Echo_debug ()
{
- STRING="${1}"
- shift
-
if [ "${_DEBUG}" = "enabled" ]
then
+ STRING="${1}"
+ shift
+
if [ "${_L10N}" = "false" ]
then
printf "D: ${STRING}\n"
@@ -36,42 +36,109 @@ Echo_debug ()
fi
}
+Echo_debug_running ()
+{
+ if [ "${_DEBUG}" = "enabled" ]
+ then
+ STRING="${1}"
+ shift
+
+ if [ "${_L10N}" = "false" ]
+ then
+ printf "D: ${STRING}"
+ else
+ printf "D: $(eval_gettext "${STRING}")" "${@}"
+ fi
+
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf "..."
+ else
+ printf "... ${YELLOW}${BLINK}running${NO_COLOR}"
+ fi
+ fi
+}
+
Echo_error ()
{
STRING="${1}"
shift
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf "E:"
+ else
+ printf "${RED}E${NO_COLOR}:"
+ fi
+
if [ "${_L10N}" = "false" ]
then
- printf "E: ${STRING}\n" >&2
+ printf " ${STRING}" >&2
else
- (printf "E: $(eval_gettext "${STRING}")" "${@}"; echo;) >&2
+ (printf " $(eval_gettext "${STRING}")" "${@}";) >&2
fi
}
Echo_message ()
{
- STRING="${1}"
- shift
+ if [ "${_QUIET}" != "enabled" ]
+ then
+ STRING="${1}"
+ shift
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf "P:"
+ else
+ printf "${WHITE}P${NO_COLOR}:"
+ fi
+
+ if [ "${_L10N}" = "false" ]
+ then
+ printf " ${STRING}\n"
+ else
+ printf " $(eval_gettext "${STRING}")" "${@}"; echo;
+ fi
+ fi
+}
+
+Echo_message_running ()
+{
if [ "${_QUIET}" != "enabled" ]
then
+ STRING="${1}"
+ shift
+
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf "P:"
+ else
+ printf "${WHITE}P${NO_COLOR}:"
+ fi
+
if [ "${_L10N}" = "false" ]
then
- printf "P: ${STRING}\n"
+ printf " ${STRING}"
+ else
+ printf " $(eval_gettext "${STRING}")" "${@}";
+ fi
+
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf "...\n"
else
- printf "P: $(eval_gettext "${STRING}")" "${@}"; echo;
+ printf "... ${YELLOW}${BLINK}running${NO_COLOR}"
fi
fi
}
Echo_verbose ()
{
- STRING="${1}"
- shift
-
if [ "${_VERBOSE}" = "enabled" ]
then
+ STRING="${1}"
+ shift
+
if [ "${_L10N}" = "false" ]
then
printf "I: ${STRING}\n"
@@ -81,11 +148,41 @@ Echo_verbose ()
fi
}
+Echo_verbose_running ()
+{
+ if [ "${_VERBOSE}" != "enabled" ]
+ then
+ STRING="${1}"
+ shift
+
+ if [ "${_L10N}" = "false" ]
+ then
+ printf "I: ${STRING}"
+ else
+ printf "I: $(eval_gettext "${STRING}")" "${@}";
+ fi
+
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf "...\n"
+ else
+ printf "... ${YELLOW}${BLINK}running${NO_COLOR}"
+ fi
+ fi
+}
+
Echo_warning ()
{
STRING="${1}"
shift
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf "W:"
+ else
+ printf "${YELLOW}W${NO_COLOR}:"
+ fi
+
if [ "${_L10N}" = "false" ]
then
printf "W: ${STRING}\n"
@@ -94,6 +191,50 @@ Echo_warning ()
fi
}
+Echo_status ()
+{
+ __RETURN="${?}"
+
+ if [ "${_COLOR}" = "false" ]
+ then
+ if [ "${__RETURN}" = "0" ]
+ then
+ printf " done.\n"
+ else
+ printf " failed.\n"
+ fi
+ else
+ Cursor_columns_backward 8
+
+ if [ "${__RETURN}" = "0" ]
+ then
+ printf " ${GREEN}done${NO_COLOR}. \n"
+ else
+ printf " ${RED}failed${NO_COLOR}.\n"
+ fi
+ fi
+}
+
+Echo_done ()
+{
+ if [ "${_COLOR}" = "false" ]
+ then
+ printf " already done.\n"
+ else
+ Cursor_columns_backward 8
+
+ printf " ${GREEN}already done${NO_COLOR}.\n"
+ fi
+}
+
+Echo_file ()
+{
+ while read LINE
+ do
+ echo "${1}: ${LINE}"
+ done < "${1}"
+}
+
Echo_breakage ()
{
case "${LH_DISTRIBUTION}" in
@@ -107,11 +248,3 @@ Echo_breakage ()
Echo_message "${@}"
}
-
-Echo_file ()
-{
- while read LINE
- do
- echo "${1}: ${LINE}"
- done < "${1}"
-}