User friendly command line apps with even less suffering
I love to write command line applications (eg. App-iTan, Business-UPS-Tracking, Game-Lacuna-Task, Mac-iPhoto-Exif and many more not publicly available). However most of the CPAN tools I generally use to build these applications either are not as user-friendly as I would like them to be, or are not flexible enough.
I decided to change that and wrote MooseX-App.
It handles commands with multiple subcommands, generates usage text, error messages on wrong user-input, validates options, and lets you write your program as easy-to-test and reusable classes. Just as App-Cmd (or MooseX-App-Cmd respectively). However compared to these options it ...
- is more flexible
- supports plugins that can overdrive almost all of its behaviour
- does not impose a certain application structure on you (thus making code reusage and testing easier)
- does not pollute your command classes with many methods since most of its logic is implemented via meta classes
- and is quite user friendly by providing useful input hints, better error messages as well as optional colorful output and bash completion
So let me give you a short example:
Hope you like it.
I like the idea of declarative definition of command-line options, but any combination of "Moose" and "command-line" just turns me right off.
If I have to wait for Moose to load (perhaps because I don't have the "big developer's workstation" in front of me) just to find out the usage is wrong... well that gets pretty frustrating. I want my computer to work faster than I do.
Mark if speed is your main concern (I actually agree with you that sometimes it could be frustrating) you might want to check Moo and MooX::Options or some other alternative. Here is a presentation I've found a few weeks ago http://sck.to/Ro
Same here – Moose has infected so many libraries that at this point I'm writing my command-line tools in bash, python, or Node. I love Perl, but it is in danger of becoming useless for what it used to be best at.
I guess it depends on the task at hand if the performance penalty of loading Moose for a command line script is worth the wait.
MooseX::App is a framework to help making powerful and complex command line apps easier to write for the developer. I guess it's a little bit like Catalyst: If you just need one or two controller actions, than you're probably better off with something like Dancer (or even plain Plack). But for big projects frameworks that force^W help you to use some structured approach to implement your features are definitely worth the load time.
As a side note, a lot of "scripts" we (Maros is a work colleague of mine) write take a lot of options and then run for a rather long time. The startup time is totally irrelevant in those cases. Of course this maybe does not apply to your use cases, in which case MooseX::App may be the wrong tool for you. Thankfully, CPAN provides several other tools. And you can still fuzz with @ARGV yourself, if you really want to go there (for that extra millisecond).