File Coverage

blib/lib/Dancer2/CLI.pm
Criterion Covered Total %
statement 15 28 53.5
branch 0 2 0.0
condition n/a
subroutine 5 12 41.6
pod 0 1 0.0
total 20 43 46.5


line stmt bran cond sub pod time code
1             package Dancer2::CLI;
2             # ABSTRACT: Dancer2 CLI application
3             $Dancer2::CLI::VERSION = '2.0.1';
4 1     1   347823 use Moo;
  1         10918  
  1         8  
5 1     1   2650 use CLI::Osprey;
  1         50834  
  1         15  
6 1     1   101288 use Path::Tiny;
  1         3  
  1         82  
7 1     1   700 use File::Share 'dist_dir';
  1         38615  
  1         104  
8 1     1   12 use Module::Runtime 'use_module';
  1         2  
  1         10  
9              
10             subcommand gen => 'Dancer2::CLI::Gen';
11             subcommand 'gen-app' => 'Dancer2::CLI::Gen';
12              
13             # Could have done this one inline, but wanted to remain consistent
14             # across subcommands.
15             subcommand version => 'Dancer2::CLI::Version';
16              
17             # Thinking ahead, these might be useful in future subcommands
18             has _dancer2_version => (
19             is => 'lazy',
20 0     0     builder => sub { use_module( 'Dancer2' )->VERSION },
21             );
22              
23             has _dist_dir => (
24             is => 'lazy',
25 0     0     builder => sub{ dist_dir('Dancer2') },
26             );
27              
28             sub run {
29 0     0 0   my $self = shift;
30 0           return $self->osprey_usage;
31             }
32              
33             sub _get_app_path {
34 0     0     my ( $self, $path, $appname ) = @_;
35 0           return path( $path, $self->_get_dashed_name( $appname ));
36             }
37              
38             sub _get_app_file {
39 0     0     my ( $self, $appname ) = @_;
40 0           $appname =~ s{::}{/}g;
41 0           return path( 'lib', "$appname.pm" );
42             }
43              
44             sub _get_perl_interpreter {
45 0 0   0     return -r '/usr/bin/env' ? '#!/usr/bin/env perl' : "#!$^X";
46             }
47              
48             sub _get_dashed_name {
49 0     0     my ( $self, $name ) = @_;
50 0           $name =~ s{::}{-}g;
51 0           return $name;
52             }
53              
54             1;
55              
56             __END__