RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

A zero-dependency Ruby CLI boilerplate class (with boilerplate tests)

Have you ever wanted to add a simple CLI to one of your small Ruby libraries, but did not want to add the dependency for thor or some other CLI library/framework? Well now you can copy this boilerplate code for a zero-dependency Ruby CLI class! Features include:

  • Zero-dependencies, making it ideal for adding a CLI to small libraries.
  • Correctly handles Ctrl^C and broken pipe exceptions (aka $ your-cli | head).
  • Catches any other exceptions and prints a bug report.
  • Defines the CLI as a class, making it easy to test.
  • Comes with boilerplate RSpec tests.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in