From 6acde780f60e0c7ebc64a543f9653da63c936c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Wed, 26 Jun 2019 14:21:25 +0200 Subject: [PATCH] 5to6 add color support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- PVE/CLI/pve5to6.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/PVE/CLI/pve5to6.pm b/PVE/CLI/pve5to6.pm index 65d104f9..c61eb241 100644 --- a/PVE/CLI/pve5to6.pm +++ b/PVE/CLI/pve5to6.pm @@ -17,6 +17,8 @@ use PVE::RPCEnvironment; use PVE::Storage; use PVE::Tools; +use Term::ANSIColor; + use PVE::CLIHandler; use base qw(PVE::CLIHandler); @@ -47,7 +49,9 @@ my $log_line = sub { }; sub log_pass { + print color('green'); $log_line->('pass', @_); + print color('reset'); } sub log_info { @@ -57,10 +61,14 @@ sub log_skip { $log_line->('skip', @_); } sub log_warn { + print color('yellow'); $log_line->('warn', @_); + print color('reset'); } sub log_fail { + print color('red'); $log_line->('fail', @_); + print color('reset'); } my $get_pkg = sub { @@ -357,12 +365,12 @@ __PACKAGE__->register_method ({ check_misc(); print "\n\nSUMMARY:\n"; - print "PASSED: $counters->{pass}\n"; + print colored("PASSED: $counters->{pass}\n", 'green'); print "SKIPPED: $counters->{skip}\n"; - print "WARNINGS: $counters->{warn}\n"; - print "FAILURES: $counters->{fail}\n"; + print colored("WARNINGS: $counters->{warn}\n", 'yellow'); + print colored("FAILURES: $counters->{fail}\n", 'red'); - print "\nATTENTION: Please check the output for detailed information!\n" + print colored("\nATTENTION: Please check the output for detailed information!\n", 'red') if ($counters->{warn} > 0 || $counters->{fail} > 0); return undef;