This is all about Slop 3 (ruby 1.9 era). Slop 4 has changed the API. See the README And see my new blog post about a Slop 4 example.
One of my favorite features of slop is the automatic help generation. But it’s not intuitive. It doesn’t print out the help when the parsing fails. This isn’t very unix-y. So every time I want to use slop, I have to look up this snippet I saved for myself. So I’m posting it here. This is the only slop example you’ll ever need.
Unix style CLI program in Ruby
Calling it like this will fail:
Great! Then using it correctly will do this:
The resume flag is the only required one, so in this case that’s how it’s run correctly.
Update: I was very happy that @lee_jarvis (the slop author) accepted my pull request to put this example into the README.