allow LICENSE generation to fail during disttest phase
[p5sagit/Distar.git] / helpers / generate-license
index 1229056..0b3e9cc 100755 (executable)
@@ -3,11 +3,25 @@ use strict;
 use warnings;
 
 use Software::LicenseUtils;
+use Getopt::Long qw(:config gnu_getopt);
+
+GetOptions(
+  "o|output=s"    => \(my $output = '-'),
+) or die("Error in command line arguments!\n");
 
 my ($authors, @licenses) = @ARGV;
 
+my $out;
+if ($output eq '-') {
+  $out = \*STDOUT;
+}
+else {
+  open $out, '>', $output
+    or die "Unable to write to $output: $!\n";
+}
+
 my %uniq;
-print
+print { $out }
   join "\n\n",
   map { $_->new({holder => $authors})->license }
   grep { !$uniq{$_}++ }