Bug 38299: Make filehandler optional for colored outputs
Allow say_success, say_failure, etc, to omit the filehandler parameter so that they can be used without explicitly opening a filehandler if you are just printing to STDOUT and don't already have one. If a filehandler is passed, the existing behavior is unchanged. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
0be29ed976
commit
bae04ca3fd
|
|
@ -71,22 +71,42 @@ Output an informational message in blue.
|
|||
|
||||
sub say_warning {
|
||||
my ( $fh, $msg ) = @_;
|
||||
say $fh YELLOW, "$msg", RESET;
|
||||
|
||||
if ($fh) {
|
||||
say $fh YELLOW, "$msg", RESET;
|
||||
} else {
|
||||
say YELLOW, "$msg", RESET;
|
||||
}
|
||||
}
|
||||
|
||||
sub say_failure {
|
||||
my ( $fh, $msg ) = @_;
|
||||
say $fh RED, "$msg", RESET;
|
||||
|
||||
if ($fh) {
|
||||
say $fh RED, "$msg", RESET;
|
||||
} else {
|
||||
say RED, "$msg", RESET;
|
||||
}
|
||||
}
|
||||
|
||||
sub say_success {
|
||||
my ( $fh, $msg ) = @_;
|
||||
say $fh GREEN, "$msg", RESET;
|
||||
|
||||
if ($fh) {
|
||||
say $fh GREEN, "$msg", RESET;
|
||||
} else {
|
||||
say GREEN, "$msg", RESET;
|
||||
}
|
||||
}
|
||||
|
||||
sub say_info {
|
||||
my ( $fh, $msg ) = @_;
|
||||
say $fh BLUE, "$msg", RESET;
|
||||
|
||||
if ($fh) {
|
||||
say $fh BLUE, "$msg", RESET;
|
||||
} else {
|
||||
say BLUE, "$msg", RESET;
|
||||
}
|
||||
}
|
||||
|
||||
=head1 AUTHORS
|
||||
|
|
|
|||
Loading…
Reference in New Issue