Building a Sub-command Ruby CLI with just OptionParser
10-Oct-2025 573
I’ve thought deeply about building CLIs and built a lot of them over the years. I’ve used Rake, Thor, my own gem GLI and many others. After all that, the venerable OptionParser—part of Ruby’s standard library—is the best choice for scripting and sub-command (git-like) CLIs. I want to show you how.
What is a Sub-Command CLI?
At first glance, OptionParser doesn’t seem to support a sub-command CLI, like so (I’ll explain what each part is below):.
Building a Sub-command Ruby CLI with just OptionParser #ruby #rubydeveloper #rubyonrails #Building #Sub-command #OptionParser https://www.rubyonrails.ba/link/building-a-sub-command-ruby-cli-with-just-optionparser