App::Cmd – write command line apps with less suffering

July 30, 2008

I think I have a new favourite Perl module. For a while with the buildtools project I’ve been working on a way to provide a decent command line interface. Basically what I want is “tool command –opt1 –opt2”. I’ve been using a combination of option handling done with MooseX::Getopt and a hash lookup table to convert commands to classes. This has the rather unsatisfactory issue of needing the command lookup table to be hardwired somewhere.

I had also come up against some other issues with handling things like providing help to the user (i.e. a list of commands and their options). Although seemingly a minor issue, good tools will never be accepted if they are not extensible and self-documenting.

Yesterday I gave up trying to hack the current system to death to get it to do what I want and decide it need a larger change. One quick conversion on the #moose irc channel ( led me to discover the App::Cmd module and, even better, MooseX::App::Cmd. The particularly nice bit is that the Moose extension module works with MooseX::Getopt so the changes needed were fairly small.