From: Intransition Date: 2010-06-14T04:43:01+09:00 Subject: Re: State of the union for Ruby CLI libraries? On Jun 13, 12:07 pm, John Feminella wrote: > I am starting construction on a somewhat complicated internal > application whose primary interface will be the command line. In the > past, for similar projects, I've just used OptionParser, but I think I > need something a little beefier. Specifically, I think I need these > features: > > * colorized output > * sensible option parsing > * sensible enumeration of options for help output > * support for `git`-like subcommands, e.g., `app create`, `app > delete`, etc., that can be intuitively and cleanly mapped to methods > * ability to be insensitive to option ordering, e.g. `app create --foo > quux --bar` should be semantically identical to `app create --bar > --foo quux` > > Does that sort of thing exist? I've noticed there are some apparently > more powerful alternatives like Thor, which is more of a full-stack > scripting framework, and I'm wondering what else might be useful to > take a look at. > > Any and all suggestions would be much appreciated. Thanks! OptionParser generally works fine --even for the items you mention. To handle subcommands just pop off the top of ARGV before parsing (or for more advanced use, find the first non-option item). The order of options is not an issue, and help is pretty easy since OptionPaser responds to #to_s. Running that through a colorizing filter shouldn't be too hard. For color try http://rubyworks.github.com/ansi. There are other options out there though, check out HighLine and Oyster for instance.