@@ -14,6 +14,7 @@ msg_label=""
1414label_space=" 7"
1515adjust_chr=" "
1616customized_label=false
17+ customized_label_color=false
1718nolabel=false
1819noappname=false
1920noadjust=false
@@ -36,6 +37,7 @@ _help() {
3637 echo " -l [label] Specify the label."
3738 echo " -n | --nocolor No output colored output"
3839 echo " -o [option] Specify echo options"
40+ echo " -r [color] Specify the color of label"
3941 echo " -s [number] Specifies the label space."
4042 echo " -x | --bash-debug Enables output bash debugging"
4143 echo " -h | --help This help message"
@@ -45,8 +47,13 @@ _help() {
4547 echo " --noadjust Do not adjust the width of the label"
4648}
4749
50+ # Message functions
51+ msg_error () {
52+ " ${script_path} /tools/msg.sh" -a " msg.sh" error " ${1} "
53+ }
54+
4855
49- while getopts " a:c:l:no:s:xh-:" arg; do
56+ while getopts " a:c:l:no:r: s:xh-:" arg; do
5057 case ${arg} in
5158 a) appname=" ${OPTARG} " ;;
5259 c) adjust_chr=" ${OPTARG} " ;;
@@ -56,6 +63,39 @@ while getopts "a:c:l:no:s:xh-:" arg; do
5663 ;;
5764 n) nocolor=true ;;
5865 o) echo_opts=" ${OPTARG} " ;;
66+ r)
67+ customized_label_color=true
68+ case ${OPTARG} in
69+ " black" )
70+ labelcolor=" 30"
71+ ;;
72+ " red" )
73+ labelcolor=" 31"
74+ ;;
75+ " green" )
76+ labelcolor=" 32"
77+ ;;
78+ " yellow" )
79+ labelcolor=" 33"
80+ ;;
81+ " blue" )
82+ labelcolor=" 34"
83+ ;;
84+ " magenta" )
85+ labelcolor=" 35"
86+ ;;
87+ " cyan" )
88+ labelcolor=" 36"
89+ ;;
90+ " white" )
91+ labelcolor=" 37"
92+ ;;
93+ * )
94+ msg_error " The wrong color."
95+ exit 1
96+ ;;
97+ esac
98+ ;;
5999 s) label_space=" ${OPTARG} " ;;
60100 x)
61101 bash_debug=true
@@ -124,38 +164,38 @@ shift $((OPTIND - 1))
124164case ${1} in
125165 " info" )
126166 msg_type=" type"
127- textcolor=" 32"
128167 output=" stdout"
129- [[ " ${customized_label} " = false ]] && msg_label=" Info"
168+ [[ " ${customized_label_color} " = false ]] && labelcolor=" 32"
169+ [[ " ${customized_label} " = false ]] && msg_label=" Info"
130170 shift 1
131171 ;;
132172 " warn" )
133173 msg_type=" warn"
134- textcolor=" 33"
135174 output=" stdout"
136- [[ " ${customized_label} " = false ]] && msg_label=" Warning"
175+ [[ " ${customized_label_color} " = false ]] && labelcolor=" 33"
176+ [[ " ${customized_label} " = false ]] && msg_label=" Warning"
137177 shift 1
138178 ;;
139179 " debug" )
140180 msg_type=" debug"
141- textcolor=" 35"
142181 output=" stdout"
143- [[ " ${customized_label} " = false ]] && msg_label=" Debug"
182+ [[ " ${customized_label_color} " = false ]] && labelcolor=" 35"
183+ [[ " ${customized_label} " = false ]] && msg_label=" Debug"
144184 shift 1
145185 ;;
146186 " error" )
147187 msg_type=" error"
148- textcolor=" 31"
149188 output=" stderr"
150- [[ " ${customized_label} " = false ]] && msg_label=" Error"
189+ [[ " ${customized_label_color} " = false ]] && labelcolor=" 31"
190+ [[ " ${customized_label} " = false ]] && msg_label=" Error"
151191 shift 1
152192 ;;
153193 " " )
154- " ${script_path} /tools/msg.sh " -a " msg.sh " error " Please specify the message type"
194+ msg_error " Please specify the message type"
155195 exit 1
156196 ;;
157197 * )
158- " ${script_path} /tools/msg.sh " -a " msg.sh " error " Unknown message type"
198+ msg_error " Unknown message type"
159199 exit 1
160200 ;;
161201esac
@@ -171,7 +211,7 @@ echo_type() {
171211 done
172212 fi
173213 if [[ " ${nocolor} " = false ]]; then
174- echo -ne " \e[$( [[ -v backcolor ]] && echo -n " ${backcolor} " ; [[ -v textcolor ]] && echo -n " ;${textcolor } " ; [[ -v decotypes ]] && echo -n " ;${decotypes} " ) m${msg_label} \e[m "
214+ echo -ne " \e[$( [[ -v backcolor ]] && echo -n " ${backcolor} " ; [[ -v labelcolor ]] && echo -n " ;${labelcolor } " ; [[ -v decotypes ]] && echo -n " ;${decotypes} " ) m${msg_label} \e[m "
175215 else
176216 echo -ne " ${msg_label} "
177217 fi
0 commit comments