Skip to content

Commit dbffde7

Browse files
committed
[update] : Supported long options
1 parent dac6ac2 commit dbffde7

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

tools/msg.sh

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,33 @@ _help() {
3939
echo
4040
echo "Display a message with a colored app name and message type label"
4141
echo
42+
echo " Example: ${0} -a 'Script' -s 10 warn It is example message"
43+
echo " Output : $(bash "${msgsh}" -a "Script" -s 10 warn It is example message)"
44+
echo
4245
echo " General type:"
43-
echo " info General message"
44-
echo " warn Warning message"
45-
echo " error Error message"
46-
echo " debug Debug message"
46+
echo " info General message"
47+
echo " warn Warning message"
48+
echo " error Error message"
49+
echo " debug Debug message"
4750
echo
4851
echo " General options:"
49-
echo " -a [name] Specify the app name"
50-
echo " -c [character] Specify the character to adjust the label"
51-
echo " -l [label] Specify the label"
52-
echo " -n | --nocolor No output colored output"
53-
echo " -o [option] Specify echo options"
54-
echo " -p [output] Specify the output destination"
55-
echo " standard output: stdout"
56-
echo " error output : stderr"
57-
echo " -r [color] Specify the color of label"
58-
echo " -s [number] Specifies the label space"
59-
echo " -t [color] Specify the color of text"
60-
echo " -x | --bash-debug Enables output bash debugging"
61-
echo " -h | --help This help message"
52+
echo " -a | --appname [name] Specify the app name"
53+
echo " -c | --chr [character] Specify the character to adjust the label"
54+
echo " -l | --label [label] Specify the label"
55+
echo " -n | --nocolor No output colored output"
56+
echo " -o | --echo-option [option] Specify echo options"
57+
echo " -p | --output [output] Specify the output destination"
58+
echo " standard output: stdout"
59+
echo " error output : stderr"
60+
echo " -r | --label-color [color] Specify the color of label"
61+
echo " -s | --label-space [number] Specifies the label space"
62+
echo " -t | --text-color [color] Specify the color of text"
63+
echo " -x | --bash-debug Enables output bash debugging"
64+
echo " -h | --help This help message"
6265
echo
63-
echo " --nolabel Do not output label"
64-
echo " --noappname Do not output app name"
65-
echo " --noadjust Do not adjust the width of the label"
66+
echo " --nolabel Do not output label"
67+
echo " --noappname Do not output app name"
68+
echo " --noadjust Do not adjust the width of the label"
6669
}
6770

6871
# text [-b/-c color/-f/-l/]
@@ -118,25 +121,25 @@ check_color(){
118121

119122
ARGUMENT=("${@}")
120123
OPTS="a:c:l:no:p:r:s:t:xh"
121-
OPTL="nocolor,bash-debug,help,nolabel,noappname,noadjust"
124+
OPTL="appname:,chr:,label:,nocolor,echo-option:,output:,label-color:,label-space:,text-color:,bash-debug,help,nolabel,noappname,noadjust"
122125
if ! OPT=($(getopt -o ${OPTS} -l ${OPTL} -- "${ARGUMENT[@]}")); then
123126
exit 1
124127
fi
125128

126129
eval set -- "${OPT[@]}"
127-
unset OPT OPTS OPTL
130+
unset OPT OPTS OPTL ARGUMENT
128131

129132
while true; do
130133
case "${1}" in
131-
-a)
134+
-a | --appname)
132135
appname="${2}"
133136
shift 2
134137
;;
135-
-c)
138+
-c | --chr)
136139
adjust_chr="${2}"
137140
shift 2
138141
;;
139-
-l)
142+
-l | --label)
140143
customized_label=true
141144
msg_label="${2}"
142145
shift 2
@@ -145,16 +148,16 @@ while true; do
145148
nocolor=true
146149
shift 1
147150
;;
148-
-o)
151+
-o | --echo-option)
149152
echo_opts+=(${2})
150153
shift 2
151154
;;
152-
-p)
155+
-p | --output)
153156
output="${2}"
154157
customized_output=true
155158
shift 2
156159
;;
157-
-r)
160+
-r | --label-color)
158161
customized_label_color=true
159162
if check_color "${2}"; then
160163
labelcolor="${2}"
@@ -164,11 +167,11 @@ while true; do
164167
fi
165168
shift 2
166169
;;
167-
-s)
170+
-s | --label-space)
168171
label_space="${2}"
169172
shift 2
170173
;;
171-
-t)
174+
-t | --text-color)
172175
customized_text_color=true
173176
if check_color "${2}"; then
174177
textcolor="${2}"

0 commit comments

Comments
 (0)