Add a --show-series argument to the tdwtf CLI
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 19 Mar 2016 18:26:35 +0000 (20:26 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 19 Mar 2016 18:26:35 +0000 (20:26 +0200)
lib/App/TDWTF.pm
tdwtf

index a8276dd243b758941e6f99f1c1f7a932678809af..b31574280ba55edf4ea6001381ab9409461312c4 100644 (file)
@@ -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 40d8e46db536b3adb83abd38813c6f54301ca530..8c102e962360857f9809c63a7a50da48f648a808 100755 (executable)
--- 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
 
This page took 0.010436 seconds and 4 git commands to generate.