#!/usr/bin/env perl
use
open
qw(:std :utf8)
;
my
%Opts
;
my
$Usage
=
<<EOS;
Usage:
$0 -T format [-as] [-o output-file] [file]
See the man page frundis(1) for detailed information.
EOS
unless
(getopts(
"T:so:a"
, \
%Opts
)) {
die
$Usage
;
}
die
"frundis:fatal:-T option required\n$Usage"
unless
defined
$Opts
{T};
my
$file
=
@ARGV
?
shift
@ARGV
:
undef
;
if
(
$Opts
{a} and
$Opts
{T} eq
"epub"
) {
warn
"frundis:warning:-a option doesn't make sense when exporting to epub\n"
;
}
if
(
$Opts
{T} eq
"epub"
and not
defined
$Opts
{o}) {
die
"frundis:fatal:when exporting to epub the name of the generated "
.
"directory should be specified with the -o option\n"
;
}
if
(
$Opts
{T} eq
"xhtml"
and not
$Opts
{a}
and not
defined
$Opts
{o})
{
die
"frundis:fatal:when exporting to xhtml, unless -a is specified, "
.
"-o option is mandatory\n"
;
}
my
%options
= (
target_format
=>
$Opts
{T},
output_file
=>
$Opts
{o},
standalone
=>
$Opts
{s},
all_in_one_file
=>
$Opts
{a},
use_carp
=> 0,
script
=> 1,
input_file
=>
$file
,
);
my
$frundis
= Text::Frundis->new;
$frundis
->process_source(
%options
);
exit
0;