From 8ce432aab8074d6d3353ca198afe1861f8fa7fee Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 26 Sep 2004 12:39:29 +0000 Subject: [PATCH] Options. --- temple | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/temple b/temple index 6f07483..2db9c30 100755 --- 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 ] ..."; +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 []"; + open STDOUT, ">$out" or die "Cannot open $out: $!"; +} +if (!@ARGV) { push @ARGV, "-"; } +UCW::Temple::start(); +foreach (@ARGV) { + UCW::Temple::parse_file($_); } +UCW::Temple::finish(); -- 2.39.5