forked from check-spelling/check-spelling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
output-covers.pl
executable file
·32 lines (29 loc) · 1003 Bytes
/
output-covers.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env perl
use JSON::PP;
my $prefixes=$ENV{INPUT_DICTIONARY_SOURCE_PREFIXES};
my %prefix_map;
if ($prefixes) {
%prefix_map=%{decode_json $prefixes};
}
my $dictionary_alias_pattern=$ENV{dictionary_alias_pattern};
$/=undef;
my $json=<>;
my $decoded=decode_json $json;
my @suggested_dictionaries=@{$decoded};
for my $suggested_dictionary_ref (@suggested_dictionaries) {
my %suggested_dictionary = %{$suggested_dictionary_ref};
for my $dict (keys %suggested_dictionary) {
my $suggested_dictionary_ref = $suggested_dictionary{$dict};
my @suggested_dictionary_array = @{$suggested_dictionary_ref};
my ($covers, $total, $uniq) = @suggested_dictionary_array;
my $url = $dict;
for my $key (keys %prefix_map) {
$url =~ s<$key:><$prefix_map{$key}>;
}
my $unique = '';
if ($uniq) {
$unique = " ($uniq uniquely)";
}
print "[$dict]($url) ($total) covers $covers of them$unique\n";
}
}