diff options
author | Daniel Baumann <daniel@debian.org> | 2008-11-01 16:31:26 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2011-03-09 19:03:44 +0100 |
commit | c225229f2910ee138873ecb05b43e8ec3021918d (patch) | |
tree | 0d356298e9e443cd3141ff04ee359ee04faf1224 /functions/echo.sh | |
parent | 776a7b22271178949bf6f2676e26eefb6144ce11 (diff) | |
download | vyos-live-build-c225229f2910ee138873ecb05b43e8ec3021918d.tar.gz vyos-live-build-c225229f2910ee138873ecb05b43e8ec3021918d.zip |
Implementing colorful output (currently disabled by default, though).
Diffstat (limited to 'functions/echo.sh')
-rwxr-xr-x | functions/echo.sh | 173 |
1 files changed, 153 insertions, 20 deletions
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}" -} |