File Coverage

blib/lib/Dist/Zilla/App/Command/new.pm
Criterion Covered Total %
statement 6 22 27.2
branch 0 8 0.0
condition 0 3 0.0
subroutine 2 7 28.5
pod 5 5 100.0
total 13 45 28.8


line stmt bran cond sub pod time code
1             package Dist::Zilla::App::Command::new 6.029;
2             # ABSTRACT: mint a new dist
3              
4 4     4   2719 use Dist::Zilla::Pragmas;
  4         10  
  4         26  
5              
6 4     4   33 use Dist::Zilla::App -command;
  4         9  
  4         33  
7              
8             #pod =head1 SYNOPSIS
9             #pod
10             #pod Creates a new Dist-Zilla based distribution under the current directory.
11             #pod
12             #pod $ dzil new Main::Module::Name
13             #pod
14             #pod There are two arguments, C<-p> and C<-P>. C<-P> specify the minting profile
15             #pod provider and C<-p> - the profile name.
16             #pod
17             #pod The default profile provider first looks in the
18             #pod F<~/.dzil/profiles/$profile_name> and then among standard profiles, shipped
19             #pod with Dist::Zilla. For example:
20             #pod
21             #pod $ dzil new -p work Corporate::Library
22             #pod
23             #pod This command would instruct C<dzil> to look in F<~/.dzil/profiles/work> for a
24             #pod F<profile.ini> (or other "profile" config file). If no profile name is given,
25             #pod C<dzil> will look for the C<default> profile. If no F<default> directory
26             #pod exists, it will use a very simple configuration shipped with Dist::Zilla.
27             #pod
28             #pod $ dzil new -P Foo Corporate::Library
29             #pod
30             #pod This command would instruct C<dzil> to consult the Foo provider about the
31             #pod directory of 'default' profile.
32             #pod
33             #pod Furthermore, it is possible to specify the default minting provider and profile
34             #pod in the F<~/.dzil/config.ini> file, for example:
35             #pod
36             #pod [%Mint]
37             #pod provider = FooCorp
38             #pod profile = work
39             #pod
40             #pod =cut
41              
42 0     0 1   sub abstract { 'mint a new dist' }
43              
44 0     0 1   sub usage_desc { '%c new %o <ModuleName>' }
45              
46             sub opt_spec {
47 0     0 1   [ 'profile|p=s', 'name of the profile to use',
48             { default => 'default' } ],
49              
50             [ 'provider|P=s', 'name of the profile provider to use',
51             { default => 'Default' } ],
52              
53             # [ 'module|m=s@', 'module(s) to create; may be given many times' ],
54             }
55              
56             sub validate_args {
57 0     0 1   my ($self, $opt, $args) = @_;
58              
59 0           require MooseX::Types::Perl;
60              
61 0 0         $self->usage_error('dzil new takes exactly one argument') if @$args != 1;
62              
63 0           my $name = $args->[0];
64              
65 0 0 0       $name =~ s/::/-/g if MooseX::Types::Perl::is_ModuleName($name)
66             and not MooseX::Types::Perl::is_DistName($name);
67              
68 0 0         $self->usage_error("$name is not a valid distribution name")
69             unless MooseX::Types::Perl::is_DistName($name);
70              
71 0           $args->[0] = $name;
72             }
73              
74             sub execute {
75 0     0 1   my ($self, $opt, $arg) = @_;
76              
77 0           my $dist = $arg->[0];
78              
79 0           require Dist::Zilla::Dist::Minter;
80 0           my $stash = $self->app->_build_global_stashes;
81             my $minter = Dist::Zilla::Dist::Minter->_new_from_profile(
82             ( exists $stash->{'%Mint'} ?
83 0 0         [ $stash->{'%Mint'}->provider, $stash->{'%Mint'}->profile ] :
84             [ $opt->provider, $opt->profile ]
85             ),
86             {
87             chrome => $self->app->chrome,
88             name => $dist,
89             _global_stashes => $stash,
90             },
91             );
92              
93 0           $minter->mint_dist({
94             # modules => $opt->module,
95             });
96             }
97              
98             1;
99              
100             __END__
101              
102             =pod
103              
104             =encoding UTF-8
105              
106             =head1 NAME
107              
108             Dist::Zilla::App::Command::new - mint a new dist
109              
110             =head1 VERSION
111              
112             version 6.029
113              
114             =head1 SYNOPSIS
115              
116             Creates a new Dist-Zilla based distribution under the current directory.
117              
118             $ dzil new Main::Module::Name
119              
120             There are two arguments, C<-p> and C<-P>. C<-P> specify the minting profile
121             provider and C<-p> - the profile name.
122              
123             The default profile provider first looks in the
124             F<~/.dzil/profiles/$profile_name> and then among standard profiles, shipped
125             with Dist::Zilla. For example:
126              
127             $ dzil new -p work Corporate::Library
128              
129             This command would instruct C<dzil> to look in F<~/.dzil/profiles/work> for a
130             F<profile.ini> (or other "profile" config file). If no profile name is given,
131             C<dzil> will look for the C<default> profile. If no F<default> directory
132             exists, it will use a very simple configuration shipped with Dist::Zilla.
133              
134             $ dzil new -P Foo Corporate::Library
135              
136             This command would instruct C<dzil> to consult the Foo provider about the
137             directory of 'default' profile.
138              
139             Furthermore, it is possible to specify the default minting provider and profile
140             in the F<~/.dzil/config.ini> file, for example:
141              
142             [%Mint]
143             provider = FooCorp
144             profile = work
145              
146             =head1 PERL VERSION
147              
148             This module should work on any version of perl still receiving updates from
149             the Perl 5 Porters. This means it should work on any version of perl released
150             in the last two to three years. (That is, if the most recently released
151             version is v5.40, then this module should work on both v5.40 and v5.38.)
152              
153             Although it may work on older versions of perl, no guarantee is made that the
154             minimum required version will not be increased. The version may be increased
155             for any reason, and there is no promise that patches will be accepted to lower
156             the minimum required perl.
157              
158             =head1 AUTHOR
159              
160             Ricardo SIGNES 😏 <cpan@semiotic.systems>
161              
162             =head1 COPYRIGHT AND LICENSE
163              
164             This software is copyright (c) 2022 by Ricardo SIGNES.
165              
166             This is free software; you can redistribute it and/or modify it under
167             the same terms as the Perl 5 programming language system itself.
168              
169             =cut