source: bookmarks/trunk/bkmk @ 8

Last change on this file since 8 was 2, checked in by peter, 13 years ago

Added exisiting bookmarks project files

  • Property svn:executable set to *
File size: 793 bytes
Line 
1#!/usr/bin/perl -w
2use strict;
3
4use DBI;
5use YAML;
6use Bookmarks;
7
8my $dbname = 'new.db';
9
10my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "", { RaiseError => 1, PrintError => 0 });
11
12my $bookmarks = Bookmarks->new({
13    dbh => $dbh,
14});
15
16my $command = shift;
17
18my %action_for = (
19    get => sub {
20        my $identifier = shift;
21        my $query = $identifier =~ /^\d+$/ ? { id => $identifier } : { uri => $identifier };
22        my $bookmark = $bookmarks->get_bookmark($query);
23
24        print $bookmark ? Dump($bookmark) : "Not Found\n";
25    },
26    add => sub {
27        my ($uri, $title, @tags) = @_;
28        my $bookmark = $bookmarks->add({ uri => $uri, title => $title, tags => \@tags });
29        print Dump($bookmark);
30    },
31);
32
33$action_for{$command}->(@ARGV);
34
35=begin
36
37use YAML;
38
Note: See TracBrowser for help on using the repository browser.