#!/usr/bin/perl
#
# Copyright (C) 2013 Patrick "P. J." McDermott
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
use strict;
use warnings;
use Getopt::Long;
use CGI::SSI;
sub main
{
my %opts;
my $input;
my $output;
$SIG{'__WARN__'} = \&warning;
Getopt::Long::Configure("no_ignore_case", "bundling", "gnu_compat",
"no_getopt_compat");
if (not GetOptions(\%opts,
"o=s",
"D=s%",
"I=s",
"h|help",
"V|version",
)) {
usage(*STDERR);
exit(4);
}
if (exists($opts{'h'})) {
help(*STDOUT);
exit(0);
}
if (exists($opts{'V'})) {
version(*STDOUT);
exit(0);
}
if ($#ARGV lt 0) {
error(4, "No input files\n");
}
if (exists($opts{'o'})) {
if ($#ARGV gt 0) {
error(4, "Cannot specify -o with multiple files\n");
}
compile($ARGV[0], $opts{'o'}, $opts{'D'}, $opts{'I'});
} else {
for $input (@ARGV) {
$output = $input;
$output =~ s/\.[^.]+$/.html/;
compile($input, $output, $opts{'D'}, $opts{'I'});
}
}
}
sub usage
{
my ($fh) = @_;
printf($fh "Usage: %s [-o