blib/lib/Poet/App/Command/script.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 35 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Poet::App::Command::script;
2 $Poet::App::Command::script::VERSION = '0.16';
3 use File::Spec::Functions qw(rel2abs);
4 use Poet::Tools qw(write_file);
5 use Poet::Moose;
6 use Poet::Types;
7  
8 extends 'Poet::App::Command';
9  
10 method abstract () {
11 "Create a Poet script";
12 }
13  
14 method usage_desc () {
15 return "poet script <script-name>";
16 }
17  
18 method execute ($opt, $args) {
19 $self->usage_error("takes one argument (script name)") unless @$args == 1;
20 my ($path) = @$args;
21 my $poet = $self->initialize_environment();
22 $path =~ s|^bin/||;
23 $path = rel2abs( $path, $poet->bin_dir() );
24 die "'$path' already exists, will not overwrite" if -e $path;
25 write_file( $path, $self->script_template() );
26 chmod( 0775, $path );
27 print "$path\n";
28 }
29  
30 method script_template () {
31 '#!/usr/local/bin/perl
32 use Poet::Script qw($conf $poet);
33 use strict;
34 use warnings;
35  
36 ';
37 }
38  
39 1;