These days, Git-like command line is the de facto standard. Surely you’ve seen this pattern before:
$ matrix take --with-water red.pill
When it comes to command line option parsing in Ruby, there are quite a few frameworks to choose from (OptionParser, GLI, Commander, Main, Escort, Thor and maybe a few more), but choosing the right one is difficult. After spending some time with each (read: hair pulling), I believe that Thor is currently the best option, and here’s why:
- It supports the Git-like command line pattern out of the box.
- It’s actively maintained and used by other popular frameworks (i.e. Rails).
- It allows one to create short, readable code.
- It keeps surplus features out of the code base.
- It has a Bash auto-complete generator (sort of).
- It supports multiple occurrences of the same option. This feature is (surprisingly) lacking from the other frameworks, but is quite common on the wild, i.e.
$ docker run -it --env ACCEPT_LICENSE=y --env GOBLIT=bar ...
My advice is that you don’t waste your time fiddling with the other frameworks.