package App::SCS::Role::Plugin;
+use Getopt::Long qw(GetOptionsFromArray);
use Moo::Role;
with 'App::SCS::Role::WithConfig';
sub register { return }
+sub run_cli {
+ my ($self, $env) = @_;
+ my ($command, @argv) = @{$env->{argv}};
+ return unless $command;
+ return unless my $code = $self->can(my $meth = "run_command_${command}");
+ my $run_env = { %$env };
+ if (my $proto = prototype $code) {
+ my @spec = split ';', $proto;
+ my %opt;
+ GetOptionsFromArray(\@argv, \%opt, @spec);
+ $run_env->{options} = \%opt;
+ }
+ $run_env->{argv} = \@argv;
+ $self->$meth($run_env);
+ return 1;
+}
+
1;