Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A higher level command-line oriented interface.
Ruby Other
Latest commit 7ba5aa2 @abinoam abinoam Merge pull request #178 from abinoam/feat_improve_on_code_climate
Improve scores on metric_fu and code climate


Build Status Build status Gem Version Code Climate Test Coverage Inline docs


Welcome to HighLine.

HighLine was designed to ease the tedious tasks of doing console input and output with low-level methods like gets and puts. HighLine provides a robust system for requesting data from a user, without needing to code all the error checking and validation rules and without needing to convert the typed Strings into what your program really needs. Just tell HighLine what you're after, and let it do all the work.


See: for HighLine. Specially HighLine and HighLine::Question.


require 'highline'

# Basic usage

cli =
answer = cli.ask "What do you think?"
puts "You have answered: #{answer}"

# Default answer

cli.ask("Company?  ") { |q| q.default = "none" }

# Validation

cli.ask("Age?  ", Integer) { |q| = 0..105 }
cli.ask("Name?  (last, first)  ") { |q| q.validate = /\A\w+, ?\w+\Z/ }

# Type conversion for answers:

cli.ask("Birthday?  ", Date)
cli.ask("Interests?  (comma sep list)  ", lambda { |str| str.split(/,\s*/) })

# Reading passwords:

cli.ask("Enter your password:  ") { |q| q.echo = false }
cli.ask("Enter your password:  ") { |q| q.echo = "x" }

# ERb based output (with HighLine's ANSI color tools):

cli.say("This should be <%= color('bold', BOLD) %>!")

# Menus:

cli.choose do |menu|
  menu.prompt = "Please choose your favorite programming language?  "
  menu.choice(:ruby) { say("Good choice!") }
  menu.choices(:python, :perl) { say("Not from around here, are you?") }

If you want to save some characters, you can inject/import HighLine methods on Kernel by doing the following. Just be sure to avoid name collisions in the top-level namespace.

require 'highline/import'

say "Now you can use #say directly"

For more examples see the examples/ directory of this project.


HighLine from version >= 1.7.0 requires ruby >= 1.9.3


To install HighLine, use the following command:

$ gem install highline

(Add sudo if you're installing under a POSIX system as root)

If you're using Bundler, add this to your Gemfile:

source ""
gem 'highline'

And then run:

$ bundle

If you want to build the gem locally, use the following command from the root of the sources:

$ rake package

You can also build and install directly:

$ rake install


  1. Open an issue

  2. Fork the repository

  3. Clone it locally

    • git clone
  4. Add the main HighLine repository as the upstream remote

    • cd highline # to enter the cloned repository directory.
    • git remote add -v upstream
  5. Keep your fork in sync with upstream

    • git fetch upstream
    • git checkout master
    • git merge upstream/master
  6. Create your feature branch

    • git checkout -b your_branch
  7. Hack the source code and run the tests

    • rake test
    • rake acceptance
  8. Commit your changes

    • git commit -am "Your commit message"
  9. Push it

    • git push
  10. Open a pull request

Details on:

The Core HighLine Team

For a list of people who have contributed to the codebase, see GitHub's list of contributors.

Something went wrong with that request. Please try again.