Project

cli_tools

0.0
No commit activity in last 3 years
No release in over 3 years
A collection of helper methods for ruby CLI applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

Tools for a CLI application

A collection of helper methods for ruby CLI applications.

  • sh — shell command execution, with output capturing
  • putr — like puts, but erases current line and does not advance to a new line, invaluable for displaying things like progress bar
  • esc_... — ANSI colors for your output
  • kb_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

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request