Module: Thor::Shell::Password
- Defined in:
- lib/pullentity-client/thor/shell/password.rb
Instance Method Summary collapse
Instance Method Details
#ask_passwordly(statement, color = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pullentity-client/thor/shell/password.rb', line 8 def ask_passwordly(statement, color = nil) say("#{statement} ", color) require "Win32API" char = nil password = '' while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do break if char == 10 || char == 13 # received carriage return or newline if char == 127 || char == 8 # backspace and delete password.slice!(-1, 1) else # windows might throw a -1 at us so make sure to handle RangeError (password << char.chr) rescue RangeError end end puts return password end |