add option -m to disable colors in output

This commit is contained in:
Ben Allen 2016-02-17 20:21:08 -06:00
parent f81bc4d6d2
commit 482397e8d7
2 changed files with 33 additions and 2 deletions

View file

@ -11,7 +11,6 @@
# ------------------------------------------------------------------------------
# Load dependencies
. ./output_lib.sh
. ./helper_lib.sh
# Setup the paths
@ -38,6 +37,7 @@ usage () {
usage: ${myname} [options]
-h optional Print this help message
-m optional Disable colors in output
-l PATH optional Log output in PATH
EOF
}
@ -45,15 +45,20 @@ EOF
# Get the flags
# If you add an option here, please
# remember to update usage() above.
while getopts hl: args
outputlib='output_lib.sh'
while getopts hml: args
do
case $args in
h) usage; exit 0 ;;
m) outputlib='textout_lib.sh' ;;
l) logger="$OPTARG" ;;
*) usage; exit 1 ;;
esac
done
. ./${outputlib}
if [ -z "$logger" ]; then
logger="${myname}.log"
fi

26
textout_lib.sh Normal file
View file

@ -0,0 +1,26 @@
#!/bin/sh
bldred=''
bldgrn=''
bldblu=''
bldylw=''
txtrst=''
logit () {
printf "%b\n" "$1" | tee -a "$logger"
}
info () {
printf "%b\n" "${bldblu}[INFO]${txtrst} $1" | tee -a "$logger"
}
pass () {
printf "%b\n" "${bldgrn}[PASS]${txtrst} $1" | tee -a "$logger"
}
warn () {
printf "%b\n" "${bldred}[WARN]${txtrst} $1" | tee -a "$logger"
}
yell () {
printf "%b\n" "${bldylw}$1${txtrst}\n"
}