The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/env perl
#----------------------------------------
use strict;
use warnings FATAL => qw(all);
use FindBin; BEGIN {do "$FindBin::RealBin/libdir.pl"}
#----------------------------------------

use YATT::Lite::Breakpoint;
use YATT::Lite::Util qw(default);
use YATT::Lite::Error;
use YATT::Lite::Factory;
# XXX: 各ディレクトリに .htyattcf.xhf が有ったら? rc が有ったら?
# XXX: それらが無い状態で、 Web::* 環境での動作検証をしたいときは?

# library の追加は? <= .htyattrc で?違うよね?

my $dispatcher = YATT::Lite::Factory->load_factory_offline || do {
  require YATT::Lite::WebMVC0::SiteApp;
  YATT::Lite::WebMVC0::SiteApp->new
      (app_ns => 'MyApp'
       , namespace => ['yatt', 'perl', 'js']
       , header_charset => 'utf-8'
       , debug_cgen => $ENV{DEBUG}
       , debug_cgi  => $ENV{DEBUG_CGI}
       # , is_gateway => $ENV{GATEWAY_INTERFACE} # Too early for FastCGI.
       # , tmpl_encoding => 'utf-8'
      );
};

sub fgrep (&@);

my $nerror = 0;
foreach my $fn (@ARGV) {
  unless (fgrep {/^\s*use strict\s*;/} $fn) {
    die "[use strict] is missing! in $fn\n";
  }
  my $dir = dirname($fn);
  my $dirhandler = $dispatcher->get_dirhandler($dir);
  my $action = $dirhandler->get_action_handler(basename($fn));
}

exit 1 if $nerror;

sub fgrep (&@) {
  my ($sub, $fn) = @_;
  open my $fh, '<', $fn or die "Can't open '$fn': $!";
  local $_;
  while (<$fh>) {
    return 1 if $sub->();
  }
}