use Carp qw/croak/;
-use Object::Tiny qw/cmd args/;
+use Object::Tiny qw/cmd args policy/;
-use App::Rgit::Utils qw/validate/;
+use App::Rgit::Utils qw/validate :codes/;
=head1 NAME
=cut
my %commands;
-__PACKAGE__->action($_ => 'Once') for qw/version help daemon init/, ' ';
+__PACKAGE__->action($_ => 'Once') for qw/daemon gui help init version/, ' ';
sub new {
my ($class, %args) = &validate;
}
eval "require $action; 1" or croak "Couldn't load $action: $@";
$class->SUPER::new(
- cmd => $cmd,
- args => $args{args} || [ ],
+ cmd => $cmd,
+ args => $args{args} || [ ],
+ policy => $args{policy},
);
}
$commands{$cmd} = $pkg;
}
+=head2 C<report $conf, $repo, $status>
+
+=cut
+
+sub report {
+ my ($self) = @_;
+ my $cb = $self->policy;
+ return $_[3] ? LAST : NEXT unless $cb;
+ my $code = $cb->(@_);
+ return defined $code ? $code : NEXT;
+}
+
=head2 C<cmd>
=head2 C<args>
+=head2 C<policy>
+
Accessors.
=head2 C<run $conf>