From 9e70d73b5aa1397ec28702230faf4df537b3b29f Mon Sep 17 00:00:00 2001 From: Andinus Date: Sat, 29 Aug 2020 23:52:50 +0530 Subject: Improve feed loading behaviour Now the program won't misbehave if user enters invalid feeds & it's more flexible. Like the user can enter an invalid field, the program will skip it & goto next. --- pyxis.pl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pyxis.pl b/pyxis.pl index 96e2e9f..7aedba0 100755 --- a/pyxis.pl +++ b/pyxis.pl @@ -79,7 +79,11 @@ my %dispatch = ( : push @feeds, path($feeds_dir)->children; foreach my $feed (@feeds) { - die "pyxis: no such feed\n" unless -e $feed; + # Skip if feed file doesn't exist. + say "pyxis: unknown feed `$feed'" + and next + unless -e $feed; + for my $line ($feed->lines) { chomp $line; next if (substr($line, 0, 1) eq "#" @@ -94,6 +98,10 @@ my %dispatch = ( $twtxt{$date} = $entry; } } + # Exit if there are no feeds to load. + die "pyxis: no feed to load\n" + unless scalar keys %twtxt > 0; + require Time::Moment; my %epoch_twtxt; -- cgit 1.4.1-2-gfad0