package App::SCS::Role::Plugin;

use Moo::Role;

with 'App::SCS::Role::WithConfig';

has app => (
  is => 'ro', weak_ref => 1, required => 1,
  handles => [ 'pages' ],
);

sub page_plugins { () }

sub default_page_plugins { () }

sub page_dispatchers { () }

sub provides_pages { () }

sub register { return }

sub run_cli {
  my ($self, $env) = @_;
  my ($command, @argv) = @{$env->{argv}};
  return unless $command;
  return unless $self->can(my $meth = "run_command_${command}");
  $self->$meth({ argv => \@argv, %$env });
  return 1;
}

1;
