chiark / gitweb /
media-scraper: offline mode
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Jan 2021 11:51:02 +0000 (11:51 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Jan 2021 12:00:48 +0000 (12:00 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
media-scraper

index ba376617c2284edbea4fbbcaa1fd6fdcb105d593..cbd8e68f6098c74216e2465063a5bf302f63d0be 100755 (executable)
@@ -139,6 +139,18 @@ sub method_wikimedia ($$$) {
   };
 }
 
+our $offline;
+
+while (@ARGV && $ARGV[0] =~ m/^-/) {
+  $_ = shift @ARGV;
+  last if m/^-$/;
+  if (m/^--offline$/) {
+    $offline = 1;
+  } else {
+    die "bad option: \`$_'";
+  }
+}
+
 my $input = $ARGV[0] // die;
 $input =~ m/\.toml$/ or die "$input ?";
 my $basename = $`;
@@ -294,6 +306,12 @@ END
     }
     die "$lupstream $!" unless $!==ENOENT;
 
+    if ($offline) {
+      print DEBUG "missing.\n";
+      warn "offline but $lupstream missing\n";
+      next;
+    }
+
     $method_impl->($lbase, $lupstream, $rstem);
 
     print DEBUG "done.\n";