App/Command/add_header.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 45 CC 3 SCAR 16.1
CC
3
Cov
0%
execute
12.0
abstract
2.0
opt_spec
2.0
CRAP 5.0
1 use strict;
2 use warnings;
3  
4 package Dist::Zilla::App::Command::add_header;
5 $Dist::Zilla::App::Command::add_header::VERSION = '0.0.10';
6 # ABSTRACT: concatenate individual files from your dist into bundles
7  
8 use Dist::Zilla::App -command;
9 use Dist::Zilla::Plugin::Web::FileHeader;
10 use Path::Class;
11  
12  
13  
14 sub abstract { 'concatenate individual files from your dist into bundles' }
15  
16  
17 sub opt_spec {
18 [ 'header_filename=s' => 'a file from which to take the content of header' ],
19 [ 'to=s' => 'a file add heder to' ],
20 }
21  
22  
23 sub execute {
24 my ($self, $opt, $args) = @_;
25
26 my $zilla = $self->zilla;
27 my $header_filename = $opt->header_filename;
28 my $to = $opt->to;
29
30 die "File with header not found: $header_filename" unless -e $header_filename;
31 die "The file add header to is not exists" unless -e $to;
32
33 my $plugin = Dist::Zilla::Plugin::Web::FileHeader->new({
34 plugin_name => ':AddHeader',
35 zilla => $zilla,
36 header_filename => $header_filename
37 });
38  
39 $plugin->prepend_header_to_file($to);
40 }
41  
42 1;
43  
44 __END__