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 (irc.perl.org) 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.


Release Tools Documentation

July 29, 2008

I’ve now added another page to the build tools documentation, this time it covers the release tools:

http://www.lcfg.org/doc/buildtools/reltool.html


More build tools documentation

July 28, 2008

I’ve added a couple more pages of documentation on build tools. I’ve also started a top-level page to pull together all the links:

http://www.lcfg.org/doc/buildtools/


Build Tools Notes

July 25, 2008

Finally the build tools project is getting to the stage where it can actually be used to manage the release process of real components and packages. Quite a few have been converted to get a feel for how everything hangs together, these include the authorize, auth, boot, client, file, inventory, logserver, ngeneric, om and sysinfo components. Using the experience of converting those packages I’ve put together the beginnings of some notes on how it should be done:

This page is still very much a work-in-progress but it is a good start covering the simplest cases.

http://www.lcfg.org/doc/buildtools/convert.html

Note: In due course there will be a page listing all the LCFG CMake macros/functions and explaining what they do so don’t worry that this page only covers a few of them.

I’ve also documented the macros which are available for substitution in the source-code and specfile:

http://www.lcfg.org/doc/buildtools/macros.html

Any comments are very welcome.


Logging

July 15, 2008

I’ve been thinking a bit about logging in relation to the new LCFG build tools. I have previously come across the Log::Log4perl Perl module and thought it was a very good solution for large projects. Now there is a really nice Moose wrapper, named MooseX::Log::Log4perl, which makes it trivial to add logging to your classes.


Using CMake

July 10, 2008

The build tools project is now moving along nicely and I’ve started converting LCFG components and other software projects owned by MPU. For the first time today I had a go at building a fairly simple package (lcfg-pkgtools) using CMake. I was pleasantly surprised at how easy it was to write the necessary CMake rules for building the shared library and executable. Here’s the whole cmake file.

Note that in the case of most LCFG components it will not be necessary to actually write a single line of CMake as it will all be done automagically this is a situation where the author has to do a bit more work.