class Thor::Shell::Basic
def ask(statement, *args)
ask("Where should the file be saved?", :path => true)
ask("What is your password?", :echo => false)
ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
ask("What is the planet furthest from the sun?", :default => "Pluto")
ask("What is your name?")
==== Example
Readline.
to the current working directory on systems that support
true. This will enable tab completion for file paths relative
If the required input is a path, then set the path option to
to false to mask user input from $stdin.
If asking for sensitive information, the :echo option can be set
must be given and re-asked the question.
they will be shown a message stating that one of those answers
array of acceptable answers. If one of those is not supplied,
If asked to limit the correct responses, you can pass in an
option is ignored when limited answers are supplied.
and allows them to select that value with an empty response. This
If a default value is specified it will be presented to the user
Asks something to the user and receives a response.
def ask(statement, *args) options = args.last.is_a?(Hash) ? args.pop : {} color = args.first if options[:limited_to] ask_filtered(statement, color, options) else ask_simply(statement, color, options) end end