QM has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking for some mechanism like Getopt::Declare with these features:
Argument parsing and checking also serves as the documentation.
Works with perldoc.
Has more than one level of help, such as synopsis, basic, and extended.
Is there anything along these lines, either already existing, or pieces that I can fit together quickly?

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re: Getopt::Declare replacement?
by revdiablo (Prior) on May 07, 2006 at 23:02 UTC

    Perhaps take a look at Pod::Usage. It's even a core module as of Perl 5.6

    Update: Ah, I missed that you want argument parsing too. Pod::Usage works fine in conjunction with Getopt::Long, though if you want an all-in-one, it may not be what you're looking for.

        Argument parsing and checking also serves as the documentation.
        Don't get me wrong, your pointer to the tutorial is excellent.

        I was just hoping that actually specifying the option spec would create the pod, or vice-versa. I prefer to define everything once and only once. This includes the strings used in the options spec, which are also used in the usage, and in the documentation (if I can wedge them in everywhere) -- I usually put those in variables, and reuse them or derive other stuff from them. I use string variables and use strict vars so that if I misspell something, it's a variable name, and it's caught by Perl, instead of my curmudgeonly user.

        I also realize that I can't have everything. (If it was easy, someone else would have a solution in the core already :) So I should spend some time and see if I can make pod work the same way as G:D.

        I'm also lazy in that I'm trying to combine usage and documentation. I should probably cut back on the usage, and split out the documentation. If I put the full docs into a sub, one of the options can call it. (Or I can go the pod2usage route...though in some sense that's got the same trouble in reverse.)

        -QM
        --
        Quantum Mechanics: The dreams stuff is made of

Re: Getopt::Declare replacement?
by herveus (Prior) on May 08, 2006 at 11:23 UTC
    Howdy!

    Getopt::Euclid may be a promising entry...

    It does the "write the POD and option defining stuff once" thing...

    yours,
    Michael