allow LICENSE generation to fail during disttest phase
[p5sagit/Distar.git] / helpers / generate-license
CommitLineData
c97878e5 1#!/usr/bin/env perl
2use strict;
3use warnings;
4
5use Software::LicenseUtils;
7fec23ed 6use Getopt::Long qw(:config gnu_getopt);
7
8GetOptions(
9 "o|output=s" => \(my $output = '-'),
10) or die("Error in command line arguments!\n");
c97878e5 11
12my ($authors, @licenses) = @ARGV;
13
7fec23ed 14my $out;
15if ($output eq '-') {
16 $out = \*STDOUT;
17}
18else {
19 open $out, '>', $output
20 or die "Unable to write to $output: $!\n";
21}
22
c97878e5 23my %uniq;
7fec23ed 24print { $out }
c97878e5 25 join "\n\n",
26 map { $_->new({holder => $authors})->license }
27 grep { !$uniq{$_}++ }
28 map { Software::LicenseUtils->guess_license_from_meta_key($_, 2) }
29 @licenses;