From 0911ac34e6ae2761f1b464817ce43d3a4e4ce14e Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 19 Mar 2016 20:26:35 +0200 Subject: [PATCH] Add a --show-series argument to the tdwtf CLI --- lib/App/TDWTF.pm | 8 ++++++++ tdwtf | 2 ++ 2 files changed, 10 insertions(+) diff --git a/lib/App/TDWTF.pm b/lib/App/TDWTF.pm index a8276dd..b315742 100644 --- a/lib/App/TDWTF.pm +++ b/lib/App/TDWTF.pm @@ -24,8 +24,16 @@ sub print_article { say HTML::FormatText->format_string($art->Body) } +sub print_series { + for my $series (tdwtf_series) { + $series->{$_} = encode 'UTF-8', ($series->{$_} // '') for keys %$series; + say $series->{Slug}, ' ', $series->{Title}, "\n", $series->{Description}, "\n"; + } +} + sub run { my ($args, @argv) = @_; + return print_series if $args->{show_series}; return print_list tdwtf_list_recent @argv if $args->{recent}; return print_list tdwtf_list_series @argv if $args->{series}; return print_list tdwtf_list_author @argv if $args->{author}; diff --git a/tdwtf b/tdwtf index 40d8e46..8c102e9 100755 --- a/tdwtf +++ b/tdwtf @@ -10,6 +10,7 @@ GetOptions( recent => \$args{recent}, series => \$args{series}, author => \$args{author}, + 'show-series' => \$args{show_series}, ); App::TDWTF::run(\%args, @ARGV); @@ -35,6 +36,7 @@ tdwtf - CLI interface to thedailywtf.com tdwtf --author snoofle # lists the most recent 8 articles by snoofle tdwtf --author snoofle 10 tdwtf --author snoofle 2015 01 + tdwtf --show-series # prints a list of all existing article series =head1 DESCRIPTION -- 2.30.2