No commit activity in last 3 years
No release in over 3 years
Collection of helper methods for terminal applications
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

TerminalHelpers

Collection of helper methods for terminal applications. Zero dependencies.

Installation

Install from rubygems:

gem install terminal_helpers

Build locally:

rake install

Usage

To start using terminal_helpers just include it into your app or class:

require 'terminal_helpers'
include TerminalHelpers

# or if you have session or somethin
class Session
  include TerminalHelpers
end

Input helpers

name     = ask('Your name')
email    = ask('Email address', :required => true, :format => :email)
zipcode  = ask('Zipcode', :format => :zipcode)
domain   = ask('Domain', :format => :domain)
password = ask_password(:confirm => true)
sure     = ask_yesno('Are you sure about this?')

Message helpers

empty_line    # print just an empty line
empty_line 50 # print 50 empty lines
prompt        # print '>' and wait for user input

Various informative methods:

info    'This is INFO message!'
display 'This is another INFO message!'
success 'This is SUCCESS message!'
warning 'This is WARNING message!'
error   'This is ERROR message', true # true means termination after printing

To enable disable colors support:

TerminalHelpers.use_colors = false # colors are enabled by default

Extras

Execute a shell command:

result = shell 'uptime'

Enable/disable terminal echo (helpful for password input):

echo_on
echo_off

License

See LICENSE file for details