Tools for modeling links between files / URLs / etc.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

109 lines
1.8 KiB

=pod
=head1 NAME
App::MarkFiles - Tools for logging command line history
=head1 SYNOPSIS
tk tk tk
=head1 INSTALLING
$ perl Build.PL
$ ./Build
$ ./Build install
=cut
package App::MarkFiles;
our ($VERSION) = '0.0.1';
use strict;
use warnings;
use DBI;
=over
=item get_dbh()
Get database handle for default commandlog database.
=cut
sub get_dbh {
my $dbfile = $ENV{HOME} . "/marks.db";
my $init_new = 0;
$init_new = 1 unless -f $dbfile;
my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", "");
# Make a new database and table(s), if needed:
create_mark_db($dbh) if $init_new;
return $dbh;
}
sub create_mark_db {
my ($dbh) = @_;
$dbh->do(<<'SQL'
CREATE TABLE marks (
id integer primary key,
path text,
datetime text
);
SQL
);
}
sub each {
my ($func) = @_;
my ($dbh) = get_dbh();
my $sth = $dbh->prepare(q{
SELECT * FROM marks ORDER BY datetime;
});
$sth->execute();
while (my $data = $sth->fetchrow_hashref()) {
$func->($data);
}
}
sub unmark {
my ($dbh) = get_dbh();
my (@paths) = @_;
my $sth = $dbh->prepare(q{
DELETE FROM marks WHERE PATH = ?;
});
foreach my $path (@paths) {
$sth->execute($path);
}
}
=back
=head1 AUTHOR
Copyright 2018 Brennen Bearnes
commandlog is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
=cut
1;