Skip to content

Is there a way to programmatically answer prompts? #166

Answered by piotrmurach
cswilliams asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Chris,

I like your solution, it's neat. Another approach could be to provide a 'scripted' input to the prompt like so:

if yes
  input = StringIO.new
  input << "y\n"
  input.rewind
  prompt = TTY::Prompt.new(input: input)
end

prompt.yes?("Do you like Ruby?")

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pboling
Comment options

Answer selected by piotrmurach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants