module Awskeyring::Input
Input
methods for Awskeyring
Public Class Methods
read_secret(prompt)
click to toggle source
Read a secret in without echoing the characters
@param [String] prompt text to prompt user with.
# File lib/awskeyring/input.rb, line 10 def self.read_secret(prompt) $stdout.print(prompt) hide_input end
Private Class Methods
hide_input()
click to toggle source
# File lib/awskeyring/input.rb, line 15 def self.hide_input # rubocop:disable Metrics/MethodLength require 'io/console' password = +'' loop do character = $stdin.getch break unless character case character when "\n", "\r" puts '' break when "\b", "\u007f" password.chop! print "\b\e[P" when "\u0003" exit 1 else print '*' password << character end end password end