diff options
author | Andinus <andinus@nand.sh> | 2020-08-29 23:52:50 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-08-29 23:52:50 +0530 |
commit | 9e70d73b5aa1397ec28702230faf4df537b3b29f (patch) | |
tree | a9b07575f32ff7179c93ba7b99bda90bac30eebe | |
parent | de04ee445dde97becdb798cfdbd684797782cf0e (diff) | |
download | pyxis-9e70d73b5aa1397ec28702230faf4df537b3b29f.tar.gz |
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.
-rwxr-xr-x | pyxis.pl | 10 |
1 files changed, 9 insertions, 1 deletions
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; |