|
@@ -244,6 +244,44 @@ sub parseArgs {
|
|
|
|
|
|
}
|
|
|
|
|
|
+sub color_print($$) {
|
|
|
+
|
|
|
+
|
|
|
+ #echo -e "\033[0mNC (No color)"
|
|
|
+ #echo -e "\033[1;37mWHITE\t\033[0;30mBLACK"
|
|
|
+ #echo -e "\033[0;34mBLUE\t\033[1;34mLIGHT_BLUE"
|
|
|
+ #echo -e "\033[0;32mGREEN\t\033[1;32mLIGHT_GREEN"
|
|
|
+ #echo -e "\033[0;36mCYAN\t\033[1;36mLIGHT_CYAN"
|
|
|
+ #echo -e "\033[0;31mRED\t\033[1;31mLIGHT_RED"
|
|
|
+ #echo -e "\033[0;35mPURPLE\t\033[1;35mLIGHT_PURPLE"
|
|
|
+ #echo -e "\033[0;33mYELLOW\t\033[1;33mLIGHT_YELLOW"
|
|
|
+ #echo -e "\033[1;30mGRAY\t\033[0;37mLIGHT_GRAY"
|
|
|
+ #
|
|
|
+ # Doing it this way likely hurts portability but
|
|
|
+ # it's better than nothing which is what I'm currently doing
|
|
|
+ # and would like to avoid additional module deps, as this
|
|
|
+ # isn't too hard to implement
|
|
|
+
|
|
|
+ my $print_string = shift;
|
|
|
+ my $color = shift;
|
|
|
+
|
|
|
+ if ( $color ne "BLUE" && $color ne "GREEN" && $color ne "RED" ) {
|
|
|
+ $logger->error("Bad color passed to color_print");
|
|
|
+ exit 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ my %color_map = (
|
|
|
+ BLUE => "\033[0;34m",
|
|
|
+ GREEN => "\033[0;32m",
|
|
|
+ RED => "\033[0;31m",
|
|
|
+ RESET => "\033[0m",
|
|
|
+ );
|
|
|
+
|
|
|
+ printf "$color_map{$color}$print_string$color_map{'RESET'}";
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
parseArgs();
|
|
|
my %sgConfig = parseSGConfig($args{'config-file'},$logger);
|
|
|
if ( defined $sgConfig{'UserWarn'} && -d ".git" ) {
|
|
@@ -271,8 +309,8 @@ if ( defined $args{'view'} ) {
|
|
|
chomp $name;
|
|
|
my $email = shellex("$gitCmd config --get user.email",$logger);
|
|
|
chomp $email;
|
|
|
- print "-->Username: $name\n-->Email: $email\n";
|
|
|
- print "On [branch] @ commit: $branch\n";
|
|
|
+ color_print("-->Username: $name\n-->Email: $email\n","BLUE");
|
|
|
+ color_print("On [branch] @ commit: $branch\n","GREEN");
|
|
|
print "$refs\n";
|
|
|
my $swpWarning = "\t# Likely a Vi .swp file";
|
|
|
|
|
@@ -280,9 +318,9 @@ if ( defined $args{'view'} ) {
|
|
|
print "* $untrackedTotal untracked file(s):\n";
|
|
|
foreach my $file ( @$untrackedRef ) {
|
|
|
if ( $file =~ m/.swp/ ) {
|
|
|
- print "\t$file $swpWarning\n";
|
|
|
+ color_print("\t$file $swpWarning\n","GREEN");
|
|
|
} else {
|
|
|
- print "\t$file\n";
|
|
|
+ color_print("\t$file\n","GREEN");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -290,9 +328,9 @@ if ( defined $args{'view'} ) {
|
|
|
print "* $modifiedTotal modified file(s):\n";
|
|
|
foreach my $file ( @$modifiedRef ) {
|
|
|
if ( $file =~ m/.swp/ ) {
|
|
|
- print "\t$file $swpWarning\n";
|
|
|
+ color_print("\t$file $swpWarning\n","GREEN");
|
|
|
} else {
|
|
|
- print "\t$file\n";
|
|
|
+ color_print("\t$file\n","GREEN");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -310,9 +348,9 @@ if ( defined $args{'view'} ) {
|
|
|
print "* $deletedTotal file(s) to be deleted from commit:\n";
|
|
|
foreach my $file ( @$deletedRef ) {
|
|
|
if ( $file =~ m/.swp/ ) {
|
|
|
- print "\t$file $swpWarning\n";
|
|
|
+ color_print("\t$file $swpWarning\n","RED");
|
|
|
} else {
|
|
|
- print "\t$file\n";
|
|
|
+ color_print("\t$file\n","RED");
|
|
|
}
|
|
|
}
|
|
|
}
|