around _run_cli => sub {
my ($orig, $self) = (shift, shift);
- if (@_ >= 2 and $_[0] eq 'dev' and $_[1] eq 'server') {
+ if (@_ >= 2 and $_[0] eq 'dev') {
require SCSite::DevMode;
Moo::Role->apply_roles_to_object($self, 'SCSite::DevMode');
- return $self->_run_dev_server(@_[2..$#_]);
+ if ($self->can("_run_dev_$_[1]")) {
+ return $self->${\"_run_dev_$_[1]"}(@_[2..$#_]);
+ } else {
+ die "No such dev mode $_[1]";
+ }
+ }
+ if (@_ >= 1 and my $code = $self->can("_run_cli_$_[0]")) {
+ shift;
+ return $self->$code(@_);
}
return $self->$orig(@_);
};
+sub _run_cli_generate {
+ my ($self, $to) = @_;
+ die "generate requires a directory to generate to"
+ unless $to and -d $to;
+ my $out = io($to);
+ foreach my $path ('', $self->pages->all_paths) {
+ my $dir = $out->catdir($path);
+ $dir->mkpath;
+ $dir->catfile('index.html')->print(
+ $self->run_test_request(GET => "$path/")->content
+ );
+ }
+ foreach my $path (map "/feed/$_/", keys %{$self->_feed_configs}) {
+ my $dir = $out->catdir($path);
+ $dir->mkpath;
+ $dir->catfile('index.atom')->print(
+ $self->run_test_request(GET => $path)->content
+ );
+ }
+}
+
+
__PACKAGE__->run_if_script;