Last change
on this file since 2 was
2,
checked in by peter, 13 years ago
|
Added exisiting bookmarks project files
|
-
Property svn:executable set to
*
|
File size:
793 bytes
|
Rev | Line | |
---|
[2] | 1 | #!/usr/bin/perl -w |
---|
| 2 | use strict; |
---|
| 3 | |
---|
| 4 | use DBI; |
---|
| 5 | use YAML; |
---|
| 6 | use Bookmarks; |
---|
| 7 | |
---|
| 8 | my $dbname = 'new.db'; |
---|
| 9 | |
---|
| 10 | my $dbh = DBI->connect("dbi:SQLite:dbname=$dbname", "", "", { RaiseError => 1, PrintError => 0 }); |
---|
| 11 | |
---|
| 12 | my $bookmarks = Bookmarks->new({ |
---|
| 13 | dbh => $dbh, |
---|
| 14 | }); |
---|
| 15 | |
---|
| 16 | my $command = shift; |
---|
| 17 | |
---|
| 18 | my %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 | |
---|
| 37 | use YAML; |
---|
| 38 | |
---|
Note: See
TracBrowser
for help on using the repository browser.