Commit | Line | Data |
---|---|---|
53ad55a5 MW |
1 | #! /usr/bin/perl |
2 | ||
3 | use autodie; | |
51dd0821 | 4 | use POSIX qw{:errno_h}; |
53ad55a5 MW |
5 | use JSON; |
6 | ||
7 | my ($dir) = @ARGV; | |
51dd0821 | 8 | eval { mkdir $dir; }; die if $@ && $@->errno != EEXIST; |
53ad55a5 MW |
9 | |
10 | local $/; | |
11 | my $js = decode_json <STDIN>; | |
12 | ||
13 | for my $e (@$js) { | |
14 | open $fh, ">", "$dir/$e->{name}.css"; | |
15 | print $fh "/* -*-css-*- */\n"; | |
16 | for my $s ($e->{sections}->@*) { | |
17 | KEY: for my $k (keys %$s) { | |
18 | next KEY if $k eq "code"; | |
19 | print $fh "/*@ $k: ", join(", ", $s->{$k}->@*), " */\n"; | |
20 | } | |
fea6c2f1 | 21 | $s->{code} =~ s/\n$//; |
53ad55a5 MW |
22 | print $fh $s->{code}, "\n"; |
23 | print $fh "/*\@END*/\n"; | |
24 | } | |
25 | close $fh; | |
26 | } |