Simplify and clean up strings and output.
Signed-off-by: Nicolás Ortega Froysa <nicolas@ortegas.org>
This commit is contained in:
parent
ec535f860c
commit
c08a9f4b40
23
pacundo.pl
23
pacundo.pl
@ -29,8 +29,8 @@ use feature qw(signatures);
|
|||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use File::ReadBackwards;
|
use File::ReadBackwards;
|
||||||
|
|
||||||
my $VERSION = "1.0";
|
my $VERSION = '1.0';
|
||||||
my $PROG_NAME = "pacundo";
|
my $PROG_NAME = 'pacundo';
|
||||||
|
|
||||||
sub print_version() {
|
sub print_version() {
|
||||||
print("$PROG_NAME v$VERSION\n");
|
print("$PROG_NAME v$VERSION\n");
|
||||||
@ -60,8 +60,8 @@ sub read_txs($num_txs = 1) {
|
|||||||
my $found_txs = 0;
|
my $found_txs = 0;
|
||||||
my $in_tx = 0;
|
my $in_tx = 0;
|
||||||
my @undo_txs;
|
my @undo_txs;
|
||||||
my $pacman_log = File::ReadBackwards->new("/var/log/pacman.log") or
|
my $pacman_log = File::ReadBackwards->new('/var/log/pacman.log') or
|
||||||
die("Failed to load pacman log file.\n$!");
|
die("Failed to load pacman log file.\n$!\n");
|
||||||
|
|
||||||
while ($found_txs < $num_txs && defined(my $line = $pacman_log->readline)) {
|
while ($found_txs < $num_txs && defined(my $line = $pacman_log->readline)) {
|
||||||
unless ($in_tx) {
|
unless ($in_tx) {
|
||||||
@ -77,18 +77,18 @@ sub read_txs($num_txs = 1) {
|
|||||||
$line =~ /\[ALPM\] (upgraded|downgraded) ([^\s]+) \((.*) -> (.*)\)/;
|
$line =~ /\[ALPM\] (upgraded|downgraded) ([^\s]+) \((.*) -> (.*)\)/;
|
||||||
push(@undo_txs,
|
push(@undo_txs,
|
||||||
{
|
{
|
||||||
'action' => $action,
|
action => $action,
|
||||||
'pkg_name' => $pkg_name,
|
pkg_name => $pkg_name,
|
||||||
'oldver' => $oldver,
|
oldver => $oldver,
|
||||||
'newver' => $newver,
|
newver => $newver,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} elsif ($line =~ /\[ALPM\] (installed|removed)/) {
|
} elsif ($line =~ /\[ALPM\] (installed|removed)/) {
|
||||||
my ($action, $pkg_name) = $line =~ /\[ALPM\] (installed|removed) ([^\s]+)/;
|
my ($action, $pkg_name) = $line =~ /\[ALPM\] (installed|removed) ([^\s]+)/;
|
||||||
push(@undo_txs,
|
push(@undo_txs,
|
||||||
{
|
{
|
||||||
'action' => $action,
|
action => $action,
|
||||||
'pkg_name' => $pkg_name,
|
pkg_name => $pkg_name,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -118,8 +118,7 @@ $n, $tx->{action}, $tx->{pkg_name}
|
|||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
print("Select transactions to undo (e.g. '1 2 3', '1-3')\n");
|
print("Select transactions to undo (e.g. '1 2 3', '1-3')\n> ");
|
||||||
print("> ");
|
|
||||||
|
|
||||||
my @sel = split(' ', <STDIN>);
|
my @sel = split(' ', <STDIN>);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user