Adding Color Using ANSI Escape Sequences
Cucumber is a great example of a command-line app that uses color effectively. Cucumber wants to motivate the user to work in a certain way. The user first writes a feature file and runs it, seeing a stream of red steps output to the terminal. As the user works to “fix” each step, the steps turn green until all the steps of all scenarios of the feature are passing, showing a pleasant stream of green steps to the terminal. Working this way can be quite satisfying, and Cucumber’s use of color is a huge part of this.
We’ll learn how to make our apps use color, by using the rainbow gem, which provides an easy way to manipulate the ANSI escape sequences that allow a terminal to show color. Before that, however, ...
Get Build Awesome Command-Line Applications in Ruby 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.