summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-07-08 14:01:52 -0400
committerJoey Hess <joey@kitenet.net>2010-07-08 14:05:39 -0400
commit7dbad39bbe93ebcc05f278965906fd1c77d2bc34 (patch)
tree7ea21efa8dfb879e648f8cd45bf9b17597c50ebd
parentd4c11466bad0e0aa3ac3c6f0bfc7577633d0d744 (diff)
Add --changesetup mode that allows easily changing options in a setup file.
-rw-r--r--debian/changelog2
-rw-r--r--doc/setup.mdwn6
-rw-r--r--doc/usage.mdwn14
-rwxr-xr-xikiwiki.in38
4 files changed, 45 insertions, 15 deletions
diff --git a/debian/changelog b/debian/changelog
index 9d88b5c9c..c340f8901 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ ikiwiki (3.20100705) UNRELEASED; urgency=low
comment moderation queue.
* aggregate: Write timestamp next aggregation can happen to
.ikiwiki/aggregatetime, to allow for more sophisticated cron jobs.
+ * Add --changesetup mode that allows easily changing options in a
+ setup file.
-- Joey Hess <joeyh@debian.org> Mon, 05 Jul 2010 13:59:42 -0400
diff --git a/doc/setup.mdwn b/doc/setup.mdwn
index 03fed3aa9..266222cc3 100644
--- a/doc/setup.mdwn
+++ b/doc/setup.mdwn
@@ -102,6 +102,12 @@ After making changes to this file, you need to tell ikiwiki to use it:
% ikiwiki -setup foo.setup
+Alternatively, you can ask ikiwiki to change settings in the file for you:
+
+ % ikiwiki -changesetup foo.setup -plugin goodstuff
+
+See [[usage]] for more options.
+
## Customizing file locations
As a wiki compiler, ikiwiki builds a wiki from files in a source directory,
diff --git a/doc/usage.mdwn b/doc/usage.mdwn
index 2f87d60d5..840d105d2 100644
--- a/doc/usage.mdwn
+++ b/doc/usage.mdwn
@@ -32,14 +32,22 @@ These options control the mode that ikiwiki operates in.
* --setup setupfile
- In setup mode, ikiwiki reads the config file, which is really a perl
- program that can call ikiwiki internal functions.
-
The default action when --setup is specified is to automatically generate
wrappers for a wiki based on data in a setup file, and rebuild the wiki.
If you only want to build any changed pages, you can use --refresh with
--setup.
+* --changesetup setupfile
+
+ Reads the setup file, adds any configuration changes specified by other
+ options, and writes the new configuration back to the setup file. Also
+ updates any configured wrappers. In this mode, the wiki is not fully
+ rebuilt, unless you also add --rebuild.
+
+ Example, to enable some plugins:
+
+ ikiwiki --changesetup ~/ikiwiki.setup --plugin goodstuff --plugin calendar
+
* --dumpsetup setupfile
Causes ikiwiki to write to the specified setup file, dumping out
diff --git a/ikiwiki.in b/ikiwiki.in
index ac43044df..aa3337938 100755
--- a/ikiwiki.in
+++ b/ikiwiki.in
@@ -14,24 +14,32 @@ sub usage () {
gettext(" ikiwiki --setup configfile"), "\n";
}
+sub setup (@) {
+ 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;
+}
+
sub getconfig () {
if (! exists $ENV{WRAPPED_OPTIONS}) {
%config=defaultconfig();
eval q{use Getopt::Long};
Getopt::Long::Configure('pass_through');
GetOptions(
- "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;
- },
+ "setup|s=s" => \&setup,
"dumpsetup|s=s" => \$config{dumpsetup},
+ "changesetup|s=s" => sub {
+ $config{changesetup}=$_[1];
+ $config{genwrappers}=1;
+ $config{refresh}=1;
+ setup(@_);
+ },
"wikiname=s" => \$config{wikiname},
"verbose|v!" => \$config{verbose},
"syslog!" => \$config{syslog},
@@ -85,7 +93,8 @@ sub getconfig () {
$config{wrappermode}=possibly_foolish_untaint($_[1])
},
"plugin=s@" => sub {
- push @{$config{add_plugins}}, $_[1];
+ push @{$config{add_plugins}}, $_[1]
+ unless grep { $_ eq $_[1] } @{$config{add_plugins}};
},
"disable-plugin=s@" => sub {
push @{$config{disable_plugins}}, $_[1];
@@ -181,6 +190,11 @@ sub main () {
}
}
+ if ($config{changesetup}) {
+ require IkiWiki::Setup;
+ IkiWiki::Setup::dump($config{changesetup});
+ }
+
if ($config{dumpsetup}) {
$config{srcdir}="" if ! defined $config{srcdir};
$config{destdir}="" if ! defined $config{destdir};