From: Martin Mares Date: Sun, 26 Sep 2004 12:39:29 +0000 (+0000) Subject: Options. X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8ce432aab8074d6d3353ca198afe1861f8fa7fee;p=temple.git Options. --- 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();