Fun with App::Prove::Plugin

Steve Purkis steve at purkis.ca
Wed Feb 4 21:29:15 GMT 2009


On 3 Feb 2009, at 12:29, Andy Armstrong wrote:

> On 3 Feb 2009, at 08:23, Steve Purkis wrote:
>> This would make it possible to set whatever you like on the app  
>> before
>> TAP::Harness ever gets called.  IE: a lot of flexibility for one lazy
>> line of code.  Of course, that would break current plugin API... but
>> then, I can only see 1 other module on CPAN that uses it.
>>
>> Thoughts?
>
>
> Well it'd certainly be nice to do something with the plugin
> architecture :)

And there was much rejoicing...  (wahaay. :)

> I'm slightly conflicted over the idea of having plugins expose first-
> class command line switches. It's cute and it saves typing - but runs
> the risk of namespace clashes. And I'm not sure it's a good UI. Having
> new options automagically appear when a plugin is installed hurts
> discoverability.
>
> On machine A I discover that prove supports the --foo option - so I
> got to machine B and try the same thing - but --foo is rejected. So I
> update App::Prove since I obviously have an out of date version - but
> --foo still doesn't work. What do I do next?

Pull your hair out?

Or: (and this is somewhat crack-fueled) make the option being parsed  
equal to the plugin name.  That way There Can Be Only One.  eg:

	prove --foo

loads the module App::Prove::Plugin::Foo if it exists.  If it doesn't,  
it tells the user:

	"Sorry, I don't know how to --foo.  Maybe you're missing the 'Foo'  
plugin?"

(If you wanted to be real clever, you could even offer to install it  
for them via CPAN.)

Then we could use some of Eric's ideas (ala Getopt::AsDocumented -  
which is a really good idea, btw) to load params the plugin can  
handle.  "Loadable modes" as Eric says.


> Perl's -M/m/d switch is a good interface from that point of view -
> because it makes it explicit that you're loading a module.

Yeah, I know what you mean.

All this talk of auto-loading plugins based on cmdline params is  
interesting & potentially useful, but it's a nice-to-have from my  
POV.  What would be definitely useful is letting the plugins modify  
the App::Prove object.  Any thoughts on that?

-Steve



More information about the tapx-dev mailing list