summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2008-11-01 16:31:26 +0100
committerDaniel Baumann <daniel@debian.org>2011-03-09 19:03:44 +0100
commitc225229f2910ee138873ecb05b43e8ec3021918d (patch)
tree0d356298e9e443cd3141ff04ee359ee04faf1224 /functions
parent776a7b22271178949bf6f2676e26eefb6144ce11 (diff)
downloadvyos-live-build-c225229f2910ee138873ecb05b43e8ec3021918d.tar.gz
vyos-live-build-c225229f2910ee138873ecb05b43e8ec3021918d.zip
Implementing colorful output (currently disabled by default, though).
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 feac48bb0..03d333c79 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 4592d2163..3636c219d 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 816221262..e5787231f 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}"
-}