Introducing Methadone, the Awesome Command-Line Library
December 19, 2011
I’ve spent the last year writing a book on building awesome command-line applications in Ruby. Over the course of writing it, I’ve used a lot of Ruby libraries for building command-line apps, and none of them work quite right. In my book, I spent significant time on OptionParser, since it’s builtin, and GLI, since I wrote it (and since it’s actually very fully-featured compare to the alternatives).
I just finished up an appendix where I showed alternate implementations of the running examples using main, thor, and trollop. I did this for a few reasons:
- These tools are popular, and people have asked if they’d be included
- They are, by and large, very different from how
OptionParserand GLI work - I wanted to give them a real shakedown
I also surveyed many other tools, but, alas, I couldn’t include everything. Each of these tools have a common theme, which is to
avoid the boilerplate of OptionParser, and make it really easy to parse command-line arguments. They all have done this, but at
a cost. All of them are less powerful and extensible than OptionParser, and only slightly more compact (or, in the case of
main, more verbose).
Enter methadone, which has all of OptionParser’s power, but the compactness of these other frameworks.

