Commit | Line | Data |
7f9d2ed9 |
1 | package Gitalist::TraitFor::Script; |
a18818fd |
2 | use Moose::Role; |
5e26dc93 |
3 | use MooseX::Types::Moose qw/ Undef /; |
a18818fd |
4 | use MooseX::Types::Common::String qw/NonEmptySimpleStr/; |
5 | use namespace::autoclean; |
6 | |
7 | has repo_dir => ( |
5e26dc93 |
8 | isa => Undef | NonEmptySimpleStr, |
9 | is => 'ro', |
10 | default => sub { |
11 | return unless exists $ENV{GITALIST_REPO_DIR}; |
12 | $ENV{GITALIST_REPO_DIR}; |
13 | }, |
a18818fd |
14 | ); |
15 | |
6537d25e |
16 | around run => sub { |
17 | my $orig = shift; |
18 | my $self = shift; |
6537d25e |
19 | local $ENV{GITALIST_REPO_DIR} = $self->repo_dir; |
20 | $self->$orig(@_); |
21 | }; |
22 | |
a18818fd |
23 | 1; |
24 | |
e56c039f |
25 | =head1 NAME |
26 | |
27 | Gitalist::ScriptRole - Role for Gitalist scripts. |
28 | |
29 | =head1 DESCRIPTION |
30 | |
31 | Wraps the run method in Catalyst scripts to apply the C<< --repo_dir >> |
32 | option. |
33 | |
34 | =head1 AUTHORS |
35 | |
36 | See L<Gitalist> for authors. |
37 | |
38 | =head1 LICENSE |
39 | |
40 | See L<Gitalist> for the license. |
41 | |
42 | =cut |