]> mj.ucw.cz Git - temple.git/blobdiff - temple
The argument of UCW::Temple::start() is no longer mandatory
[temple.git] / temple
diff --git a/temple b/temple
index 6f0748327727a0a7b25f41e4049357e48b930ea5..2db9c305cced0a33f2ec4ec2940de9dc3961049e 100755 (executable)
--- a/temple
+++ b/temple
@@ -5,14 +5,19 @@
 use strict;
 use warnings;
 
+use Getopt::Long;
 use UCW::Temple;
 
-if (@ARGV == 1) {
-       UCW::Temple::process_file($ARGV[0]);
-} elsif (@ARGV == 2) {
+my $out;
+
+GetOptions('out|o=s' => \$out) or die "Usage: temple [-o <out>] <in> ...";
+if (defined $out) {
        close STDOUT;
-       open STDOUT, ">$ARGV[1]" or die "Cannot open $ARGV[1]: $!";
-       UCW::Temple::process_file($ARGV[0]);
-} else {
-       die "Usage: temple <in> [<out>]";
+       open STDOUT, ">$out" or die "Cannot open $out: $!";
+}
+if (!@ARGV) { push @ARGV, "-"; }
+UCW::Temple::start();
+foreach (@ARGV) {
+       UCW::Temple::parse_file($_);
 }
+UCW::Temple::finish();