-sub usage () { #{{{
- die gettext("usage: ikiwiki [options] source dest"), "\n";
-} #}}}
+sub usage () {
+ die gettext("usage: ikiwiki [options] source dest"), "\n",
+ gettext(" ikiwiki --setup configfile"), "\n";
+}
if (! exists $ENV{WRAPPED_OPTIONS}) {
%config=defaultconfig();
eval q{use Getopt::Long};
Getopt::Long::Configure('pass_through');
GetOptions(
if (! exists $ENV{WRAPPED_OPTIONS}) {
%config=defaultconfig();
eval q{use Getopt::Long};
Getopt::Long::Configure('pass_through');
GetOptions(
- "setup|s=s" => \$config{setup},
+ "setup|s=s" => sub {
+ require IkiWiki::Setup;
+ my $verbose=$config{verbose};
+ my $syslog=$config{syslog};
+ IkiWiki::Setup::load($_[1]);
+ $config{setupverbose}=$config{verbose};
+ $config{setupsyslog}=$config{syslog};
+ $config{verbose}=$verbose || $config{setupverbose};
+ $config{syslog}=$syslog;
+ $config{setup}=1;
+ },
"dumpsetup|s=s" => \$config{dumpsetup},
"wikiname=s" => \$config{wikiname},
"verbose|v!" => \$config{verbose},
"syslog!" => \$config{syslog},
"rebuild!" => \$config{rebuild},
"refresh!" => \$config{refresh},
"dumpsetup|s=s" => \$config{dumpsetup},
"wikiname=s" => \$config{wikiname},
"verbose|v!" => \$config{verbose},
"syslog!" => \$config{syslog},
"rebuild!" => \$config{rebuild},
"refresh!" => \$config{refresh},
"post-commit" => \$config{post_commit},
"render=s" => \$config{render},
"post-commit" => \$config{post_commit},
"render=s" => \$config{render},
- "wrappers!" => \$config{wrappers},
+ "wrappers!" => \$config{genwrappers},
+ "wrappergroup=s" => \$config{wrappergroup},
"usedirs!" => \$config{usedirs},
"prefix-directives!" => \$config{prefix_directives},
"getctime" => \$config{getctime},
"usedirs!" => \$config{usedirs},
"prefix-directives!" => \$config{prefix_directives},
"getctime" => \$config{getctime},
},
"disable-plugin=s@" => sub {
push @{$config{disable_plugins}}, $_[1];
},
"disable-plugin=s@" => sub {
push @{$config{disable_plugins}}, $_[1];
- usage() unless @ARGV == 2;
- $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
- $config{destdir} = possibly_foolish_untaint(shift @ARGV);
- checkconfig();
+ if (@ARGV == 2) {
+ $config{srcdir} = possibly_foolish_untaint(shift @ARGV);
+ $config{destdir} = possibly_foolish_untaint(shift @ARGV);
+ checkconfig();
+ }
+ else {
+ usage() unless $config{dumpsetup};
+ }
- require IkiWiki::Setup;
- IkiWiki::Setup::load($config{setup});
- if (! $config{render} && ! $config{dumpsetup} &&
- (! $config{refresh} || $config{wrappers})) {
+ delete $config{setup};
+ loadplugins();
+ checkconfig();
+
+ if (@{$config{wrappers}} &&
+ ! $config{render} && ! $config{dumpsetup} &&
+ ! $config{clean} &&
+ ((! $config{refresh} && ! $config{post_commit})
+ || $config{genwrappers})) {
debug(gettext("generating wrappers.."));
require IkiWiki::Wrapper;
my %origconfig=(%config);
debug(gettext("generating wrappers.."));
require IkiWiki::Wrapper;
my %origconfig=(%config);
- my @wrappers=@{$config{wrappers}};
- delete $config{wrappers};
- foreach my $wrapper (@wrappers) {
- %config=(%origconfig,
- rebuild => 0,
- verbose => 0,
- %{$wrapper},
- );
+ foreach my $wrapper (@{$config{wrappers}}) {
+ %config=(%origconfig, %{$wrapper});
+ $config{verbose}=$config{setupverbose}
+ if exists $config{setupverbose};
+ $config{syslog}=$config{setupsyslog}
+ if exists $config{setupsyslog};
+ delete @config{qw(setupsyslog setupverbose wrappers genwrappers rebuild)};
- require IkiWiki::Setup::Standard;
- IkiWiki::Setup::Standard::dump($config{dumpsetup});
+ $config{srcdir}="" if ! defined $config{srcdir};
+ $config{destdir}="" if ! defined $config{destdir};
+ $config{syslog}=1 if $config{setupsyslog};
+ require IkiWiki::Setup;
+ IkiWiki::Setup::dump($config{dumpsetup});
+ elsif ($config{clean}) {
+ require IkiWiki::Render;
+ foreach my $wrapper (@{$config{wrappers}}) {
+ prune($wrapper->{wrapper});
+ }
+ clean_rendered();
+ system("rm", "-rf", $config{wikistatedir});
+ }