enquirer v0.1.0 Enquirer

Enquirer is a simple module to make is easy to get user input in terminal applications.

Summary

Functions

Asks the user a yes/no question. A default can be supplied. A true result indicates a “yes” answer. false indicated “no”

Allows the user to choose between options. An optional default can be supplied

Gets input from the user

Asks the user a to enter a list of items. A blank line is treated as the end of the input

Outputs a string to the terminal, optionaly specifying a colour. Valid colours are :red, :green and :yellow

Functions

ask(question, default \\ true)

Asks the user a yes/no question. A default can be supplied. A true result indicates a “yes” answer. false indicated “no”

Without a default:

ask "Do you like oranges?"

With a default:

ask "So you like oranges?", false
choose(question, opts)

Allows the user to choose between options. An optional default can be supplied.

Without a default:

choose "What is your favourite colour?",
  red:    "Red",
  green:  "Green",
  yellow: "Yellow"

With a default:

choose "What is your favourite colour?",
  red:     "Red",
  green:   "Green",
  yellow:  "Yellow",
  default: :yellow
get(question)

Gets input from the user.

get "What is your name?"
get_list(question)

Asks the user a to enter a list of items. A blank line is treated as the end of the input

get_list "Enter your favourite colours"
say(something, colour \\ nil)

Outputs a string to the terminal, optionaly specifying a colour. Valid colours are :red, :green and :yellow