about summary refs log tree commit diff stats
path: root/pyxis.pl
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-08-29 23:52:50 +0530
committerAndinus <andinus@nand.sh>2020-08-29 23:52:50 +0530
commit9e70d73b5aa1397ec28702230faf4df537b3b29f (patch)
treea9b07575f32ff7179c93ba7b99bda90bac30eebe /pyxis.pl
parentde04ee445dde97becdb798cfdbd684797782cf0e (diff)
downloadpyxis-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.
Diffstat (limited to 'pyxis.pl')
-rwxr-xr-xpyxis.pl10
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;