Sign in to PrePAN

OptArgs integrated argument and option processing



use OptArgs;

opt quiet => (
     isa     => 'Bool',
     alias   => 'q',
    comment => 'be quiet please',

arg item => (
    isa     => 'Str',
    default => 1,
    comment => 'try this many times',

my $ref = optargs;
print "Working on: $ref->{item}\n" unless $ref->{quiet};


This module combines two ideas: the first is declarative syntax made successful by Moose. The second idea is to have a command processing module that doesn't stop with options, but also evaluates command arguments. The documentation s not quite complete, but the implementation is pretty close to being finished.


This should probably go under the Getopt namespace:
There are bazillions of modules like this, such as AppConfig, Config::All, etc. Is it really necessary to make another one?
Anonymous, do you have a suggestion for a name? The reason why I havent used Getopt::Something is because this isn't just about Options, which everything else under Getopt::* is about, and that space carries so much baggage.

I searched for combined option and argument processing for Perl and I found nothing that came even close to my needs. Those "bazillions" you speak of are either unmarketed, poorly named, poorly documented, or over-complicated. The fact that so many modules exist in this space without a clear winner is evidence that the problem has not yet been solved well to most people's satisfaction. So while it is not "necessary" that I make another one, I believe a fresh way of approaching the problem does no harm.

As for your two suggestions: I have read the documentation for AppConfig (plus submodules) untill my eyes glazed over and I still don't know how to use it. Configuration files? CGI parameters? For processing command options and arguments, really? And where do I find Config::All? + google returns no results.

If getting started with OptArgs is as clean and easy as your synopsis suggests, I think it will be a much welcome addition to CPAN.
> Those "bazillions" you speak of are either unmarketed, poorly named, poorly documented, or over-complicated.
Welcome to CPAN.
> And where do I find Config::All?
Sorry, I meant "Config::Any".
Your module seems interesting. I don't know enough the existing modules in Getopt:: to tell if something similar already exists.
But at least I don't see how puting your module outside the Getopt:: namespace will make it easier to find.
For the moment I have duplicated OptArgs as Getopt::Args, in the interests of visibility, although finding anything in that namespace is very tiring process. I'll be curious to see who find what....

Please sign up to post a review.