Module: AbideDevUtils::Prompt

Defined in:
lib/abide_dev_utils/prompt.rb

Class Method Summary collapse

Class Method Details

.passwordObject



26
27
28
# File 'lib/abide_dev_utils/prompt.rb', line 26

def self.password
  $stdin.getpass('Password:')
end

.secure(msg) ⇒ Object



30
31
32
# File 'lib/abide_dev_utils/prompt.rb', line 30

def self.secure(msg)
  $stdin.getpass(msg)
end

.single_line(msg) ⇒ Object



16
17
18
19
# File 'lib/abide_dev_utils/prompt.rb', line 16

def self.single_line(msg)
  print "#{msg}: "
  $stdin.cooked(&:gets).chomp
end

.usernameObject



21
22
23
24
# File 'lib/abide_dev_utils/prompt.rb', line 21

def self.username
  print 'Username: '
  $stdin.cooked(&:gets).chomp
end

.yes_no(msg, auto_approve: false) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/abide_dev_utils/prompt.rb', line 7

def self.yes_no(msg, auto_approve: false)
  return true if auto_approve

  print "#{msg} (Y/n): "
  return true if $stdin.cooked(&:gets).match?(/^[Yy].*/)

  false
end