a8276dd243b758941e6f99f1c1f7a932678809af
[webservice-tdwtf.git] / lib / App / TDWTF.pm
1 package App::TDWTF;
2
3 use 5.014000;
4 use strict;
5 use warnings;
6
7 use Encode qw/encode/;
8 use HTML::FormatText;
9 use WebService::TDWTF;
10
11 our $VERSION = '0.001';
12
13 sub print_list {
14 my $idlen = length $_[0]->Id;
15 for my $art (@_) {
16 my $str = sprintf "%${idlen}d %s (by %s) in %s on %s\n", $art->Id, $art->Title, $art->AuthorName, $art->SeriesTitle, $art->DisplayDate;
17 print encode 'UTF-8', $str;
18 }
19 }
20
21 sub print_article {
22 my ($art) = @_;
23 printf "%s (by %s) in %s on %s\n\n", $art->Title, $art->AuthorName, $art->SeriesTitle, $art->DisplayDate;
24 say HTML::FormatText->format_string($art->Body)
25 }
26
27 sub run {
28 my ($args, @argv) = @_;
29 return print_list tdwtf_list_recent @argv if $args->{recent};
30 return print_list tdwtf_list_series @argv if $args->{series};
31 return print_list tdwtf_list_author @argv if $args->{author};
32 print_article tdwtf_article @argv
33 }
This page took 0.022159 seconds and 3 git commands to generate.