- return unless $plugins[0];
- my $caller=caller(0);
- no strict 'refs';
- push @{"${caller}::ISA"}, $self;
- "Maypole::$_"->require && unshift @ISA, "Maypole::$_" foreach (@plugins);
+ my $caller = caller(0);
+ no strict 'refs';
+ push @{"${caller}::ISA"}, $self;
+ my $autosetup=0;
+ foreach (sort @plugins) {
+ if (/^\-Setup$/) { $autosetup++; }
+ elsif (/^\-Debug$/) {
+ *{"$caller\::debug"} = sub { 1 };
+ warn "Debugging enabled";
+ }
+ elsif (/^-.*$/) { warn "Unknown flag: $_" }
+ else {
+ # The plugin caller should be our application class
+ eval "package $caller; require Maypole::Plugin::$_";
+ if ($@) { warn qq(Loading plugin "Maypole::Plugin::$_" failed: $@) }
+ else {
+ warn "Loaded plugin: Maypole::Plugin::$_" if $caller->debug;
+ unshift @ISA, "Maypole::Plugin::$_";
+ }
+ }
+ }
+
+ $caller->config(Maypole::Config->new);
+ $caller->setup() if $autosetup;