projects
/
infodrom.org
/
service.infodrom.org
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0f61f9e
)
Colorise list output
author
Joey Schulze
<joey@infodrom.org>
Wed, 10 Jul 2019 20:18:32 +0000
(22:18 +0200)
committer
Joey Schulze
<joey@infodrom.org>
Wed, 10 Jul 2019 20:18:32 +0000
(22:18 +0200)
src/InfoCon/stempel/stempel
patch
|
blob
|
history
diff --git
a/src/InfoCon/stempel/stempel
b/src/InfoCon/stempel/stempel
index
7bb7bbc
..
ad7bb0a
100755
(executable)
--- a/
src/InfoCon/stempel/stempel
+++ b/
src/InfoCon/stempel/stempel
@@
-23,6
+23,7
@@
use warnings;
use DBI;
use Getopt::Long;
use Term::ReadLine;
use DBI;
use Getopt::Long;
use Term::ReadLine;
+use Term::ANSIColor;
my $table = "stempel";
my $engine = "dbi:Pg:dbname=infocon";
my $table = "stempel";
my $engine = "dbi:Pg:dbname=infocon";
@@
-273,12
+274,25
@@
sub list
my $sth = $dbh->prepare ($query);
my $sth = $dbh->prepare ($query);
+ my $customer = '';
+ my @colors = qw/blue green yellow red cyan magenta/;
+ my $color = $#colors;
if ($sth && $sth->execute > 0) {
while ((my $row = $sth->fetchrow_hashref)) {
if (defined $row->{time}) {
if ($sth && $sth->execute > 0) {
while ((my $row = $sth->fetchrow_hashref)) {
if (defined $row->{time}) {
+ if ($customer ne $row->{customer}) {
+ $customer = $row->{customer};
+ if ($color == $#colors) {
+ $color = 0;
+ } else {
+ $color++;
+ }
+ }
my $day = (split(/ /, $row->{start}))[0];
my $time = min2hour $row->{time};
my $day = (split(/ /, $row->{start}))[0];
my $time = min2hour $row->{time};
- printf "%-15s %s %s %s\n", $row->{customer}, $day, $time, $row->{task};
+ print color($colors[$color]);
+ printf "%-15s %s %s %s", $row->{customer}, $day, $time, $row->{task};
+ print color('reset'), "\n";
}
}
}
}
}
}