root/trunk/plagger/bin/plagger-search

Revision 1391 (checked in by miyagawa, 14 years ago)

merge from hackathon-mt

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Encode;
6 use FindBin;
7 use Getopt::Long;
8
9 use lib File::Spec->catdir($FindBin::Bin, '..', 'lib');
10 use Plagger;
11
12 my $path = "$FindBin::Bin/../config.yaml";
13 GetOptions("--config=s", \$path);
14 Getopt::Long::Configure("bundling"); # allows -c
15
16 my $context = Plagger->new(config => $path);
17 my $query = Encode::decode_utf8($ARGV[0]);
18
19 my @feeds = $context->search($query);
20
21 my $feed = $feeds[0];
22 binmode STDOUT, ":utf8";
23 print "Search for '$query': ", $feed->count, " entries found.\n\n";
24
25 for my $entry ($feed->entries) {
26     print $entry->title, $entry->author ? "(by " . $entry->author . ")" : '', "\n";
27     print $entry->body; # summary
28     print $entry->permalink, "\n";
29 }
30
Note: See TracBrowser for help on using the browser.