add checkall dev command to look for botched pages
[scpubgit/SCS.git] / lib / SCSite / DevMode.pm
index e0f446a..e33ab23 100644 (file)
@@ -2,6 +2,7 @@ package SCSite::DevMode;
 
 use Plack::App::File;
 use Plack::Runner;
+use Try::Tiny;
 use Moo::Role;
 
 has _static_handler => (is => 'lazy');
@@ -30,4 +31,18 @@ sub _run_dev_server {
   $r->run;
 }
 
+sub _run_dev_checkall {
+  my ($self) = @_;
+  my $ps = $self->pages;
+  foreach my $path ($ps->all_paths) {
+    try {
+      $ps->get({ path => $path });
+      print "OK ${path}\n";
+    } catch {
+      print "ERROR ${path}\n";
+      print "  $_";
+    };
+  }
+}
+
 1;