Tools for a CLI application
A collection of helper methods for ruby CLI applications.
sh— shell command execution, with output capturingputr— likeputs, but erases current line and does not advance to a new line, invaluable for displaying things like progress baresc_...— ANSI colors for your outputkb_getkey— get the f.. key pressed in a non-blocking way- and other little friends
Requirements
You probably need a Unix based system to find this gem useful. The gem methods are tested and working on Mac OS X and Linux systems, and it is not guaranteed to work on Windows (especially because the console input/output is done the unix way).
Installation
Add this line to your application's Gemfile:
gem 'cli_tools'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cli_tools
Usage
Keep all helper methods in CliTools namespace:
require 'cli_tools'
puts CliTools.esc_green("Hello")+' world!' # outputs 'Hello world!' where 'Hello' is painted green
OR: have all the methods automatically included:
require 'cli_tools/include' # equivalent to:
# require 'cli_tools'
# include CliTools
puts esc_green("Hello")+' world!'
Try it out
cd examples/
ruby ex-ansi.rb
TODO
- add more specs
- write comprehensive docs
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request