| 1 | package Mojolicious::Command::Author::generate::plugin; | ||||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Command'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | |||||||||||||
| 4 | 1 | ▶ | use Mojo::Util qw(camelize class_to_path getopt); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 1 | has description => 'Generate Mojolicious plugin directory structure'; | |||||||||||
| 7 | 1 | ▶ | has usage => sub { shift->extract_usage }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 3 | ▶ | sub run { | ||||||||||
|
Subroutine
run: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||
| 10 | 3 | my ($self, @args) = @_; | |||||||||||
| 11 | |||||||||||||
| 12 | 3 | ▶ | die $self->usage unless getopt \@args, 'f|full' => \(my $full); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 13 | |||||||||||||
| 14 | # Class | ||||||||||||
| 15 | 2 | ▶ | my $name = $args[0] // 'MyPlugin'; | ||||||||||
|
Condition100%2/2
$args[0] // "MyPlugin"
MC/DC100%1/1
$args[0] // "MyPlugin"
$args[0]
Truth table100%2/2
A
A= $args[0]
| |||||||||||||
| 16 | 2 | ▶ | my $class = $full ? $name : "Mojolicious::Plugin::$name"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | 2 | my $dir = join '-', split(/::/, $class); | |||||||||||
| 18 | 2 | my $app = class_to_path $class; | |||||||||||
| 19 | 2 | $self->render_to_rel_file('class', "$dir/lib/$app", {class => $class, name => $name}); | |||||||||||
| 20 | |||||||||||||
| 21 | # Test | ||||||||||||
| 22 | 2 | $self->render_to_rel_file('test', "$dir/t/basic.t", {name => $name}); | |||||||||||
| 23 | |||||||||||||
| 24 | # Makefile | ||||||||||||
| 25 | 2 | $self->render_to_rel_file('makefile', "$dir/Makefile.PL", {class => $class, path => $app}); | |||||||||||
| 26 | } | ||||||||||||
| 27 | |||||||||||||
| 28 | 1 | 1; | |||||||||||
| 29 | |||||||||||||
| 30 | =encoding utf8 | ||||||||||||
| 31 | |||||||||||||
| 32 | =head1 NAME | ||||||||||||
| 33 | |||||||||||||
| 34 | Mojolicious::Command::Author::generate::plugin - Plugin generator command | ||||||||||||
| 35 | |||||||||||||
| 36 | =head1 SYNOPSIS | ||||||||||||
| 37 | |||||||||||||
| 38 | Usage: APPLICATION generate plugin [OPTIONS] [NAME] | ||||||||||||
| 39 | |||||||||||||
| 40 | mojo generate plugin | ||||||||||||
| 41 | mojo generate plugin TestPlugin | ||||||||||||
| 42 | mojo generate plugin -f MyApp::Plugin::AwesomeFeature | ||||||||||||
| 43 | |||||||||||||
| 44 | Options: | ||||||||||||
| 45 | -f, --full Do not prepend "Mojolicious::Plugin::" to the plugin name | ||||||||||||
| 46 | -h, --help Show this summary of available options | ||||||||||||
| 47 | |||||||||||||
| 48 | =head1 DESCRIPTION | ||||||||||||
| 49 | |||||||||||||
| 50 | L<Mojolicious::Command::Author::generate::plugin> generates directory structures for fully functional L<Mojolicious> | ||||||||||||
| 51 | plugins. | ||||||||||||
| 52 | |||||||||||||
| 53 | This is a core command, that means it is always enabled and its code a good example for learning to build new commands, | ||||||||||||
| 54 | you're welcome to fork it. | ||||||||||||
| 55 | |||||||||||||
| 56 | See L<Mojolicious::Commands/"COMMANDS"> for a list of commands that are available by default. | ||||||||||||
| 57 | |||||||||||||
| 58 | =head1 ATTRIBUTES | ||||||||||||
| 59 | |||||||||||||
| 60 | L<Mojolicious::Command::Author::generate::plugin> inherits all attributes from L<Mojolicious::Command> and implements | ||||||||||||
| 61 | the following new ones. | ||||||||||||
| 62 | |||||||||||||
| 63 | =head2 description | ||||||||||||
| 64 | |||||||||||||
| 65 | my $description = $plugin->description; | ||||||||||||
| 66 | $plugin = $plugin->description('Foo'); | ||||||||||||
| 67 | |||||||||||||
| 68 | Short description of this command, used for the command list. | ||||||||||||
| 69 | |||||||||||||
| 70 | =head2 usage | ||||||||||||
| 71 | |||||||||||||
| 72 | my $usage = $plugin->usage; | ||||||||||||
| 73 | $plugin = $plugin->usage('Foo'); | ||||||||||||
| 74 | |||||||||||||
| 75 | Usage information for this command, used for the help screen. | ||||||||||||
| 76 | |||||||||||||
| 77 | =head1 METHODS | ||||||||||||
| 78 | |||||||||||||
| 79 | L<Mojolicious::Command::Author::generate::plugin> inherits all methods from L<Mojolicious::Command> and implements the | ||||||||||||
| 80 | following new ones. | ||||||||||||
| 81 | |||||||||||||
| 82 | =head2 run | ||||||||||||
| 83 | |||||||||||||
| 84 | $plugin->run(@ARGV); | ||||||||||||
| 85 | |||||||||||||
| 86 | Run this command. | ||||||||||||
| 87 | |||||||||||||
| 88 | =head1 SEE ALSO | ||||||||||||
| 89 | |||||||||||||
| 90 | L<Mojolicious>, L<Mojolicious::Guides>, L<https://mojolicious.org>. | ||||||||||||
| 91 | |||||||||||||
| 92 | =cut | ||||||||||||
| 93 | |||||||||||||
| 94 | __DATA__ | ||||||||||||