From 2c6340efb09a38fa5c29c17ad564e7426520203e Mon Sep 17 00:00:00 2001 From: Dennis Kaarsemaker Date: Wed, 31 Aug 2011 18:32:24 +0200 Subject: [PATCH] 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. --- cpanspec | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cpanspec b/cpanspec index c938e74..0cae552 100755 --- a/cpanspec +++ b/cpanspec @@ -109,6 +109,10 @@ Force overwriting an existing spec file. Normally B will refuse to overwrite an existing spec file for safety. This option 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> The name and email address of the packager. Overrides the C<%packager> @@ -222,6 +226,7 @@ our $perl_version=0; our $addlicense=0; our $noprefix=0; our $force=0; +our $stdout=0; our $packager; our $release=1; our $epoch; @@ -539,6 +544,7 @@ GetOptions( 'license|l' => \$addlicense, 'noprefix|n' => \$noprefix, 'force|f' => \$force, + 'stdout|S' => \$stdout, 'packager|p=s' => \$packager, 'release|r=i' => \$release, 'epoch|e=i' => \$epoch, @@ -817,7 +823,9 @@ for my $file (@args) { verbose "Writing $specfile..."; my $spec; - if ($force) { + if ($stdout) { + $spec = *STDOUT; + } elsif ($force) { rename($specfile, "$specfile~") if (-e $specfile); $spec=new FileHandle ">$specfile"; } else {