diff options
| author | Philipp Schafft <lion@lion.leolix.org> | 2017-05-01 10:45:43 +0000 |
|---|---|---|
| committer | Philipp Schafft <lion@lion.leolix.org> | 2017-05-01 16:15:00 +0000 |
| commit | 5a5730104f306313ec4f9d6aab04fa37a48b86fe (patch) | |
| tree | 553bc7b9f0bc2b3c9a8c1a1cedfc78a9a8380450 /webgen-blog | |
| parent | 3617eed54e553a602e26f5f4d0e2440b2ff20687 (diff) | |
Update: Support webgen's parameters for plugins
Diffstat (limited to 'webgen-blog')
| -rwxr-xr-x | webgen-blog | 21 |
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'}}) { |
