Skip to content

Commit 2773e5e

Browse files
committed
add utility function: warning notice fatal_warning attention.
1 parent 7b1e48d commit 2773e5e

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

utils.pm

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ package utils;
1111
use FileHandle;
1212
use Getopt::Long;
1313
use Time::Local qw(timelocal);
14+
use Term::ANSIColor;
1415
use strict;
1516
$|=1;
1617

@@ -19,7 +20,8 @@ BEGIN {
1920
use vars qw($VERSION @ISA @EXPORT);
2021
@ISA = qw(Exporter);
2122
@EXPORT = qw(&read_rcfile &mk_fd_nonblocking &clrscr &clreol &delline
22-
&gotoxy &hidecursor &showcursor &get_winsize);
23+
&gotoxy &hidecursor &showcursor &get_winsize
24+
&notice &warning &fatal_warning &attention);
2325
}
2426

2527
#read the content of configure file.
@@ -125,3 +127,39 @@ sub get_winsize {
125127

126128
return ($row, $col);
127129
}
130+
131+
# print notice message in color of green.
132+
sub notice {
133+
my $message = shift;
134+
135+
print color "green";
136+
print "$message\n";
137+
print color "reset";
138+
}
139+
140+
# print warning message in color of yellow.
141+
sub warning {
142+
my $message = shift;
143+
144+
print color "yellow";
145+
print "$message\n";
146+
print color "reset";
147+
}
148+
149+
# print fatal_warning message in color of red.
150+
sub fatal_warning {
151+
my $message = shift;
152+
153+
print color "red";
154+
print "$message\n";
155+
print color "reset";
156+
}
157+
158+
# print attention message in color of blue.
159+
sub attention {
160+
my $message = shift;
161+
162+
print color "blue";
163+
print "$message\n";
164+
print color "reset";
165+
}

0 commit comments

Comments
 (0)