pericmd 005: Getopt::Long::Descriptive

Getopt::Long::Descriptive is an option parsing library that is based on Getopt::Long, but basically allows you to specify short summary for each option (as well as default value, or whether an option is required, or the list of valid values for the option). This has the effect of allowing the module to generate a nicer help message for you. It’s written by RJBS and is quite popular: last I checked, there are a bit over 50 other CPAN distributions using it, making it perhaps the most popular option parsing library aside from Getopt::Long itself.

As with any sane Getopt::Long-based library, it turns on bundling and no_ignore_case configurations. It integrates a fast (but minimal) validation library Params::Validate to let you specify some restrictions on the values that you want your options to accept.

I guess my minor nitpick with this module is the interface: I would’ve probably picked another name for its main function describe_options and would avoid using OO, but that’s a personal taste issue.

I haven’t personally used it yet because I’ve written Perinci::CmdLine which more or less does the same thing (and more). GL::Descriptive is, like Getopt::Long, still just an option parsing library and what I need is an CLI library/framework. For example, it doesn’t do tab completion or POD generation, even though the arguments fed to describe_options was quite enough for the features. (A comment was posted on a previous blog post about MooX::Options and MooX::Cmd which are full-blown CLI framework based on GL:Descriptive, and I will most probably discuss those on this series, eventually.)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s