Question
Ask questions to humans. Somebody has to select one of the specified answers typing the character(s) in the square brackets.
Installation
Add this line to your application's Gemfile:
gem 'questions'
And then execute:
$ bundle
Or install it via:
$ gem install questions
Usage
Preamble
require "questions"
include QuestionsLong way
q = Question.new("File does exist, what should be done?")
q.answers = [:skip, :overwrite, :abort]
answer = q.ask
# SHELL:
# $ File does exist, what should be done? [s]kip, [o]verwrite, [a]bort
# s<enter>
answer #=> :skipShort way
answer = Question.ask "File does exist, what should be done?", [:skip, :overwrite, :abort]
# SHELL:
# $ File does exist, what should be done? [s]kip, [o]verwrite, [a]bort
# s<enter>
answer #=> :skipHashish way
answer = Question.ask "File does exist, what should be done?", skip: true, overwrite: false, abort: true
# SHELL:
# $ File does exist, what should be done? [s]kip, [a]bort
# s<enter>
answer #=> :skipWay with reaction
case Question.ask "Please select:", [:next, :exit]
when :next then next
when :exit then exit
endContributing
- Fork it
- Create your feature branch (
git checkout -b feature-[short_description]orgit checkout -b fix-[github_issue_number]-[short_description]) - Commit your changes (
git commit -am 'Add some feature with tests') - Push to the branch (
git push origin [branch-name]) - Create new Pull Request