| 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__ |