Merge remote branch 'origin/model-from-args'
[catagits/Gitalist.git] / lib / Gitalist / ScriptRole.pm
CommitLineData
a18818fd 1package Gitalist::ScriptRole;
2use Moose::Role;
3use MooseX::Types::Common::String qw/NonEmptySimpleStr/;
4use namespace::autoclean;
5
6has repo_dir => (
7 isa => NonEmptySimpleStr, is => 'ro',
8 predicate => 'has_repo_dir'
9);
10
11before 'run' => sub {
12 my $self = shift;
13 if ($self->has_repo_dir) {
14 # FIXME - This seems gross. I should be able to pass things through
15 # to the app instance, but the params are sent to the engine
16 # and not actually used to construct the app.. Not that
17 # $ENV{GITLIST_REPO_DIR} is a bad move, just that that being
18 # the mechanism by which this works that is non optimum.
19 $ENV{GITALIST_REPO_DIR} = $self->repo_dir;
20 }
21};
22
231;
24
e56c039f 25=head1 NAME
26
27Gitalist::ScriptRole - Role for Gitalist scripts.
28
29=head1 DESCRIPTION
30
31Wraps the run method in Catalyst scripts to apply the C<< --repo_dir >>
32option.
33
34=head1 AUTHORS
35
36See L<Gitalist> for authors.
37
38=head1 LICENSE
39
40See L<Gitalist> for the license.
41
42=cut