Module: Net::SSH::PromptMethods::Clear

Defined in:
lib/net/ssh/prompt.rb

Overview

Defines the prompt method to use when neither Highline nor Termios are installed.

Instance Method Summary collapse

Instance Method Details

#prompt(prompt, echo = true) ⇒ Object

Displays the prompt to $stdout and pulls the response from $stdin. Text is always echoed in the clear, regardless of the echo setting. The first time a prompt is given and echo is false, a warning will be written to $stderr recommending that either Highline or Termios be installed.



64
65
66
67
68
69
70
71
72
73
74
# File 'lib/net/ssh/prompt.rb', line 64

def prompt(prompt, echo=true)
  @seen_warning ||= false
  if !echo && !@seen_warning
    $stderr.puts "Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text."
    @seen_warning = true
  end

  $stdout.print(prompt)
  $stdout.flush
  $stdin.gets.chomp
end