| 1 |
package Dancer2::CLI; |
| 2 |
# ABSTRACT: Dancer2 CLI application |
| 3 |
$Dancer2::CLI::VERSION = '2.2.2'; |
| 4 |
use Moo; |
| 5 |
use CLI::Osprey; |
| 6 |
use Path::Tiny; |
| 7 |
use File::Share 'dist_dir'; |
| 8 |
use Module::Runtime 'use_module'; |
| 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 |
builder => sub { use_module( 'Dancer2' )->VERSION }, |
| 21 |
); |
| 22 |
|
| 23 |
has _dist_dir => ( |
| 24 |
is => 'lazy', |
| 25 |
builder => sub{ dist_dir('Dancer2') }, |
| 26 |
); |
| 27 |
|
| 28 |
sub run { |
| 29 |
my $self = shift; |
| 30 |
return $self->osprey_usage; |
| 31 |
} |
| 32 |
|
| 33 |
sub _get_app_path { |
| 34 |
my ( $self, $path, $appname ) = @_; |
| 35 |
return path( $path, $self->_get_dashed_name( $appname )); |
| 36 |
} |
| 37 |
|
| 38 |
sub _get_app_file { |
| 39 |
my ( $self, $appname ) = @_; |
| 40 |
$appname =~ s{::}{/}g; |
| 41 |
return path( 'lib', "$appname.pm" ); |
| 42 |
} |
| 43 |
|
| 44 |
sub _get_perl_interpreter { |
| 45 |
return -r '/usr/bin/env' ? '#!/usr/bin/env perl' : "#!$^X"; |
| 46 |
} |
| 47 |
|
| 48 |
sub _get_dashed_name { |
| 49 |
my ( $self, $name ) = @_; |
| 50 |
$name =~ s{::}{-}g; |
| 51 |
return $name; |
| 52 |
} |
| 53 |
|
| 54 |
1; |
| 55 |
|
| 56 |
__END__ |
| 57 |
|
| 58 |
=pod |
| 59 |
|
| 60 |
=encoding UTF-8 |
| 61 |
|
| 62 |
=head1 NAME |
| 63 |
|
| 64 |
Dancer2::CLI - Dancer2 CLI application |
| 65 |
|
| 66 |
=head1 VERSION |
| 67 |
|
| 68 |
version 2.2.2 |
| 69 |
|
| 70 |
=head1 AUTHOR |
| 71 |
|
| 72 |
Dancer Core Developers |
| 73 |
|
| 74 |
=head1 COPYRIGHT AND LICENSE |
| 75 |
|
| 76 |
This software is copyright (c) 2026 by Alexis Sukrieh. |
| 77 |
|
| 78 |
This is free software; you can redistribute it and/or modify it under |
| 79 |
the same terms as the Perl 5 programming language system itself. |
| 80 |
|
| 81 |
=cut |