Build Awesome Command-Line Applications in Ruby

Control Your Computer, Simplify Your Life

Ruby Gems for Command-Line Apps

One of the toughest things about writing command-line apps in Ruby is finding the right gems. There’s tons out there, but they can be really hard to find, either due to names that are too generic (main) or too bizzare (trollop). Searching on RubyGems and Github is OK, but not great. While speaking at conferences and writing the book, I came across a ton of wonderful gems for writing command-line apps. This page is an attempt to catalog them all.


Colored Output | Command Suite | Documentation | Framework | In Book | Parsing | Progressbar | Recommended | Simple | Subprocess | Table | Testing | UI | User I/O | Validation

Colored Output

  • Paint - Color your output using RGB, with support for 256-color terminals
  • Term-ansicolor - Create colored output
  • Rainbow - Create colored output

Command Suite

  • Thor - Create a command-suite app simply and easily, as well as Rails generators
  • Main - A class factory and DSL for generating command line programs real quick.
  • GLI - Create awesome, polished command suites without a lot of code
  • Commander - Create command suites with a rake-like syntax
  • CRI - Create simple or command-suites with a syntax that is a mix of main and GLI.
  • Optitron - Create command-suites based on classes and methods, similar to thor.
  • Escort - A library that makes building command-line apps in ruby so easy, you’ll feel like an expert is guiding you through it
  • sysexits - Constants for canonical UNIX system exit codes

Documentation

  • Gem-man - Read man pages installed with gems a la man
  • Ronn - Author man pages in Markdown

Framework

  • Methadone - Bootstrap your command line app, get all the power of OptionParser, but none of the verbosity
  • Thor - Create a command-suite app simply and easily, as well as Rails generators
  • GLI - Create awesome, polished command suites without a lot of code
  • executable - Executable is to commandline what ActiveRecord is to the database
  • Escort - A library that makes building command-line apps in ruby so easy, you’ll feel like an expert is guiding you through it

In Book

  • Methadone - Bootstrap your command line app, get all the power of OptionParser, but none of the verbosity
  • Thor - Create a command-suite app simply and easily, as well as Rails generators
  • Trollop - Parse the command-line idiomatically without a lot of code
  • Main - A class factory and DSL for generating command line programs real quick.
  • GLI - Create awesome, polished command suites without a lot of code
  • Rainbow - Create colored output
  • Terminal-Table - Create ASCII tables in your output, similar to a SQL clienbt
  • Gem-man - Read man pages installed with gems a la man
  • Ronn - Author man pages in Markdown

Parsing

  • Methadone - Bootstrap your command line app, get all the power of OptionParser, but none of the verbosity
  • Thor - Create a command-suite app simply and easily, as well as Rails generators
  • Trollop - Parse the command-line idiomatically without a lot of code
  • Main - A class factory and DSL for generating command line programs real quick.
  • GLI - Create awesome, polished command suites without a lot of code
  • Choice - Command-line parser for simple command-line apps
  • Commander - Create command suites with a rake-like syntax
  • CRI - Create simple or command-suites with a syntax that is a mix of main and GLI.
  • Mixlib-CLI - Maintained by Opscode, the maintainers of chef, this can create simple command-line apps in a readable, if verbose, syntax
  • Optitron - Create command-suites based on classes and methods, similar to thor.
  • Slop - Create simple command-line apps with a syntax similar to trollop.
  • executable - Executable is to commandline what ActiveRecord is to the database
  • CLI.K - A very simple cli method for parsing command line options.
  • clap - Command line argument parsing for simple applications.
  • Escort - A library that makes building command-line apps in ruby so easy, you’ll feel like an expert is guiding you through it

Progressbar

  • Formatador - produce rich output with a tag-like string syntax, including tables and progressbars
  • ProgressBar - create progress bars in terminal output

Recommended

  • Methadone - Bootstrap your command line app, get all the power of OptionParser, but none of the verbosity
  • Main - A class factory and DSL for generating command line programs real quick.
  • GLI - Create awesome, polished command suites without a lot of code
  • Rainbow - Create colored output
  • Command_line_reporter - Create a “report”, using unicode characters in the output for tables
  • Gem-man - Read man pages installed with gems a la man
  • Ronn - Author man pages in Markdown

Simple

  • Methadone - Bootstrap your command line app, get all the power of OptionParser, but none of the verbosity
  • Thor - Create a command-suite app simply and easily, as well as Rails generators
  • Trollop - Parse the command-line idiomatically without a lot of code
  • Main - A class factory and DSL for generating command line programs real quick.
  • Choice - Command-line parser for simple command-line apps
  • CRI - Create simple or command-suites with a syntax that is a mix of main and GLI.
  • Mixlib-CLI - Maintained by Opscode, the maintainers of chef, this can create simple command-line apps in a readable, if verbose, syntax
  • Slop - Create simple command-line apps with a syntax similar to trollop.
  • sysexits - Constants for canonical UNIX system exit codes

Subprocess

  • Methadone - Bootstrap your command line app, get all the power of OptionParser, but none of the verbosity
  • Childprocess - Cross-platform ruby library for managing child processes
  • Open4 - Open3-like library for Ruby 1.8

Table

  • Formatador - produce rich output with a tag-like string syntax, including tables and progressbars
  • Terminal-Table - Create ASCII tables in your output, similar to a SQL clienbt
  • Command_line_reporter - Create a “report”, using unicode characters in the output for tables
  • table_print - Turn objects into nicely formatted columns for easy reading - works great in Rails console with flexible formatting options

Testing

  • Construct - Create temporary directory structure for testing
  • FakeFS - Fakes out various File and related calls to simulate a filesystem without changing system files.
  • Aruba - Test your command-line app with Cucumber

UI

  • Formatador - produce rich output with a tag-like string syntax, including tables and progressbars
  • Highline - handle user input and output via a “Q&A” style API, including type conversions and validation
  • Paint - Color your output using RGB, with support for 256-color terminals
  • ProgressBar - create progress bars in terminal output
  • Term-ansicolor - Create colored output
  • Rainbow - Create colored output
  • Terminal-Table - Create ASCII tables in your output, similar to a SQL clienbt
  • Command_line_reporter - Create a “report”, using unicode characters in the output for tables
  • table_print - Turn objects into nicely formatted columns for easy reading - works great in Rails console with flexible formatting options

User I/O

  • Highline - handle user input and output via a “Q&A” style API, including type conversions and validation

Validation

  • Highline - handle user input and output via a “Q&A” style API, including type conversions and validation