Colored output for all entries

This commit is contained in:
Difrex(Denis Zheleztsov) 2014-05-12 15:25:22 +04:00
parent 6e32360a35
commit 0f7dcac60b
2 changed files with 21 additions and 6 deletions

View File

@ -49,18 +49,27 @@ sub mdo {
my $sth = $dbh->prepare($q);
my $rv = $sth->execute();
printf "%-11s %-11s %-11s %-11s\n", "ID", "NAME", "RESOURCE", "USERNAME";
use Term::ANSIColor;
printf "%-11s %-11s %-11s %-11s\n",
colored( "ID", 'white' ),
colored( "NAME", 'magenta' ),
colored( "RESOURCE", 'blue' ),
colored( "USERNAME", 'green' );
print "=========================\n";
while ( my ( $id, $name, $resource, $username )
= $sth->fetchrow_array() )
{
printf "%-11s %-11s %-11s %-11s\n",
$id, $name, $resource, $username;
colored( $id, 'white' ),
colored( $name, 'magenta' ),
colored( $resource, 'blue' ),
colored( $username, 'green' );
}
# Remove unencrypted file
my @rm_cmd = ( "rm", "-f", "$db_file" );
system(@rm_cmd) == 0 or die "Cannot remove unencrypted database! $!\n";
system(@rm_cmd) == 0
or die "Cannot remove unencrypted database! $!\n";
exit 0;
}

8
pm.pl
View File

@ -105,7 +105,13 @@ elsif ( defined($opt_s) and defined($opt_n) and defined($opt_o) ) {
my @open_cmd = ( 'xdg-open', $get_h->{resource} );
system(@open_cmd) == 0 or die "Cannot open URI: $!\n";
print "Password copied to clipboard. Trying to open uri.\n";
print color 'bold green';
print "Password copied to clipboard.\n";
print color 'reset';
print "Trying to open ";
print color 'bold blue';
print $get_h->{resource} . "\n";
print color 'reset';
}
# Remove string from db
elsif ( defined($opt_r) and defined($opt_i) ) {