blob: 0adb2b3137f817d454aed92a9f74a9d21fabc113 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
class Bundler::Thor
module LineEditor
class Basic
attr_reader :prompt, :options
def self.available?
true
end
def initialize(prompt, options)
@prompt = prompt
@options = options
end
def readline
$stdout.print(prompt)
get_input
end
private
def get_input
if echo?
$stdin.gets
else
# Lazy-load io/console since it is gem-ified as of 2.3
require "io/console" if RUBY_VERSION > "1.9.2"
$stdin.noecho(&:gets)
end
end
def echo?
options.fetch(:echo, true)
end
end
end
end
|