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