Add an option to print the generated specfile to stdout
This is useful when you want to postprocess the generated specfile in some way. We use this in our build system to merge in old changelogs and customizations.
This commit is contained in:
1 parent
3b953c0923
commit
2c6340efb0
1 file changed
+9
-1
@@ -109,6 +109,10 @@ Force overwriting an existing spec file. Normally B<cpanspec> will
|
|||||||
refuse to overwrite an existing spec file for safety. This option
|
refuse to overwrite an existing spec file for safety. This option
|
||||||
removes that safety check. Please use with caution.
|
removes that safety check. Please use with caution.
|
||||||
|
|
||||||
|
=item B<-S>, B<--stdout>
|
||||||
|
|
||||||
|
Write the generated spec file to stdout instead of a file.
|
||||||
|
|
||||||
=item B<-p>, B<--packager>
|
=item B<-p>, B<--packager>
|
||||||
|
|
||||||
The name and email address of the packager. Overrides the C<%packager>
|
The name and email address of the packager. Overrides the C<%packager>
|
||||||
@@ -222,6 +226,7 @@ our $perl_version=0;
|
|||||||
our $addlicense=0;
|
our $addlicense=0;
|
||||||
our $noprefix=0;
|
our $noprefix=0;
|
||||||
our $force=0;
|
our $force=0;
|
||||||
|
our $stdout=0;
|
||||||
our $packager;
|
our $packager;
|
||||||
our $release=1;
|
our $release=1;
|
||||||
our $epoch;
|
our $epoch;
|
||||||
@@ -539,6 +544,7 @@ GetOptions(
|
|||||||
'license|l' => \$addlicense,
|
'license|l' => \$addlicense,
|
||||||
'noprefix|n' => \$noprefix,
|
'noprefix|n' => \$noprefix,
|
||||||
'force|f' => \$force,
|
'force|f' => \$force,
|
||||||
|
'stdout|S' => \$stdout,
|
||||||
'packager|p=s' => \$packager,
|
'packager|p=s' => \$packager,
|
||||||
'release|r=i' => \$release,
|
'release|r=i' => \$release,
|
||||||
'epoch|e=i' => \$epoch,
|
'epoch|e=i' => \$epoch,
|
||||||
@@ -817,7 +823,9 @@ for my $file (@args) {
|
|||||||
verbose "Writing $specfile...";
|
verbose "Writing $specfile...";
|
||||||
|
|
||||||
my $spec;
|
my $spec;
|
||||||
if ($force) {
|
if ($stdout) {
|
||||||
|
$spec = *STDOUT;
|
||||||
|
} elsif ($force) {
|
||||||
rename($specfile, "$specfile~") if (-e $specfile);
|
rename($specfile, "$specfile~") if (-e $specfile);
|
||||||
$spec=new FileHandle ">$specfile";
|
$spec=new FileHandle ">$specfile";
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user