[pve-devel] [PATCH manager 2/2] 5to6 add color support

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Jun 26 14:21:25 CEST 2019


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 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;
-- 
2.20.1





More information about the pve-devel mailing list