summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xwebgen-blog21
1 files changed, 16 insertions, 5 deletions
diff --git a/webgen-blog b/webgen-blog
index 92f96fa..ffc42b6 100755
--- a/webgen-blog
+++ b/webgen-blog
@@ -29,7 +29,10 @@ use DateTime;
my %conf = (
'tpl' => undef,
- 'input' => undef,
+ 'mode' => 'generate',
+ 'input' => '.',
+ 'output' => '.',
+ 'kv' => {},
);
my %meta = (
@@ -46,21 +49,29 @@ my %meta = (
my %entry;
+# "webgenp-$_plugin" --tpl . --mode "$_mode" --input "$_input" --output "$_output" "$@"
+
while (my $arg = shift(@ARGV)) {
- if ($arg eq '--tpl') {
+ if ($arg eq '--tpl' || $arg eq '--mode' || $arg eq '--input' || $arg eq '--output') {
$conf{substr($arg, 2)} = shift(@ARGV) or die sprintf('Argument %s needs option', $arg);
+ } elsif ($arg eq '--kv') {
+ my ($key, $value) = (shift(@ARGV), shift(@ARGV));
+ die sprintf('Argument %s needs to options', $arg) unless defined($key) && defined($value);
+ $conf{'kv'}->{$key} = $value;
} else {
die 'Unknown arg: '.$arg;
}
}
-die 'Unknown template directory' unless defined $conf{'tpl'};
+die sprintf('Unsupported mode %s', $conf{'mode'}) unless $conf{'mode'} eq 'generate';
+die sprintf('Unsupported input %s', $conf{'input'}) unless $conf{'input'} eq '.';
+die sprintf('Unsupported output %s', $conf{'output'}) unless $conf{'output'} eq '.';
-$conf{'input'} ||= 'BLOG';
+die 'Unknown template directory' unless defined $conf{'tpl'};
chdir($conf{'tpl'}) or die $!;
-proc_input($conf{'input'});
+proc_input('BLOG');
proc_templates('.');
foreach my $type (keys %{$meta{'files'}}) {