kiss: Added KISS_COLOR to control color output

This commit is contained in:
Dylan Araps 2020-05-12 12:03:13 +03:00
parent dd825b0a14
commit f5d0fe0a5f
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
2 changed files with 13 additions and 6 deletions

14
kiss
View File

@ -15,12 +15,10 @@ log() {
# All messages are printed to stderr to allow the user to hide build
# output which is the only thing printed to stdout.
#
# '\033[1;32m' Set text to color '2' and make it bold.
# '\033[m': Reset text formatting.
# '${3:-->}': If the 3rd argument is missing, set prefix to '->'.
# '${2:+\033[1;3Xm}': If the 2nd argument exists, set text style of '$1'.
printf '\033[1;33m%s \033[m%b%s\033[m %s\n' \
"${3:-->}" "${2:+\033[1;36m}" "$1" "$2" >&2
# The l<word> variables contain escape sequence which are defined
# when '$KISS_COLOR' is equal to '1'.
printf '%b%s %b%s%b %s\n' \
"$lcol" "${3:-->}" "${lclr}${2:+$lcol2}" "$1" "$lclr" "$2"
}
war() {
@ -1590,6 +1588,10 @@ main() {
# as the environment variable should always be defined.
[ "$KISS_PATH" ] || die "\$KISS_PATH needs to be set"
# Allow the user to disable colors in output via an environment variable.
# Check this once so as to not slow down printing.
[ "$KISS_COLOR" = 0 ] || lcol='\033[1;33m' lcol2='\033[1;36m' lclr='\033[m'
# Set the location to the repository and package database.
pkg_db=var/db/kiss/installed

5
kiss.1
View File

@ -93,6 +93,11 @@ export KISS_HOOK=/path/to/script
# This can be used to have the package manager run in a "fake root".
export KISS_ROOT=/
# Whether or not to color package manager output messages.
#
# Set it to '0' to disable.
export KISS_COLOR=1
# Keep build logs around for successful builds and not just failing
# ones. Helpful when debugging.
#