label_space="7"
adjust_chr=" "
customized_label=false
+customized_label_color=false
nolabel=false
noappname=false
noadjust=false
echo " -x | --bash-debug Enables output bash debugging"
echo " -h | --help This help message"
echo
- #echo " --labelcolor Specify the color of label"
+ echo " --labelcolor Specify the color of label"
echo " --nolabel Do not output label"
echo " --noappname Do not output app name"
echo " --noadjust Do not adjust the width of the label"
}
+# Message functions
+msg_error() {
+ "${script_path}/tools/msg.sh" -a "msg.sh" error "${1}"
+}
+
+
# Parse options
ARGUMENT="${@}"
_opt_short="a:c:l:no:s:xh-:"
-_opt_long="appname:,chr:,label:,nocolor,option:,space:,bash-debug,help,nolabel,noappname,noadjust"
+_opt_long="appname:,chr:,label:,nocolor,option:,space:,bash-debug,help,labelcolor:,nolabel,noappname,noadjust"
OPT=$(getopt -o ${_opt_short} -l ${_opt_long} -- ${ARGUMENT})
[[ ${?} != 0 ]] && exit 1
noadjust=true
shift 1
;;
+ --labelcolor)
+ customized_label_color=true
+ case ${2} in
+ "black")
+ labelcolor="30"
+ ;;
+ "red")
+ labelcolor="31"
+ ;;
+ "green")
+ labelcolor="32"
+ ;;
+ "yellow")
+ labelcolor="33"
+ ;;
+ "blue")
+ labelcolor="34"
+ ;;
+ "magenta")
+ labelcolor="35"
+ ;;
+ "cyan")
+ labelcolor="36"
+ ;;
+ "white")
+ labelcolor="37"
+ ;;
+ *)
+ msg_error "The wrong color."
+ exit 1
+ ;;
+ esac
+ shift 2
+ ;;
--)
shift
break
case ${1} in
"info")
msg_type="type"
- textcolor="32"
output="stdout"
- [[ "${customized_label}" = false ]] && msg_label="Info"
+ [[ "${customized_label_color}" = false ]] && labelcolor="32"
+ [[ "${customized_label}" = false ]] && msg_label="Info"
shift 1
;;
"warn")
msg_type="warn"
- textcolor="33"
output="stdout"
- [[ "${customized_label}" = false ]] && msg_label="Warning"
+ [[ "${customized_label_color}" = false ]] && labelcolor="33"
+ [[ "${customized_label}" = false ]] && msg_label="Warning"
shift 1
;;
"debug")
msg_type="debug"
- textcolor="35"
output="stdout"
- [[ "${customized_label}" = false ]] && msg_label="Debug"
+ [[ "${customized_label_color}" = false ]] && labelcolor="35"
+ [[ "${customized_label}" = false ]] && msg_label="Debug"
shift 1
;;
"error")
msg_type="error"
- textcolor="31"
output="stderr"
- [[ "${customized_label}" = false ]] && msg_label="Error"
+ [[ "${customized_label_color}" = false ]] && labelcolor="31"
+ [[ "${customized_label}" = false ]] && msg_label="Error"
shift 1
;;
"")
- "${script_path}/tools/msg.sh" -a "msg.sh" error "Please specify the message type"
+ msg_error "Please specify the message type"
exit 1
;;
*)
- "${script_path}/tools/msg.sh" -a "msg.sh" error "Unknown message type"
+ msg_error "Unknown message type"
exit 1
;;
esac
done
fi
if [[ "${nocolor}" = false ]]; then
- echo -ne "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v textcolor ]] && echo -n ";${textcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${msg_label}\e[m "
+ echo -ne "\e[$([[ -v backcolor ]] && echo -n "${backcolor}"; [[ -v labelcolor ]] && echo -n ";${labelcolor}"; [[ -v decotypes ]] && echo -n ";${decotypes}")m${msg_label}\e[m "
else
echo -ne "${msg_label} "
fi