Class: HTTY::CLI::InputDevice::TTY
- Inherits:
-
Object
- Object
- HTTY::CLI::InputDevice::TTY
- Defined in:
- lib/htty/cli/input_device.rb
Instance Method Summary collapse
- #commands ⇒ Object
-
#initialize(display) ⇒ TTY
constructor
A new instance of TTY.
Constructor Details
#initialize(display) ⇒ TTY
Returns a new instance of TTY.
30 31 32 33 |
# File 'lib/htty/cli/input_device.rb', line 30 def initialize(display) enable_completion @display = display end |
Instance Method Details
#commands ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/htty/cli/input_device.rb', line 35 def commands loop do begin command_line = '' while command_line.empty? do if (command_line = Readline.readline(@display.formatted_prompt, true)).nil? raise Interrupt end if whitespace?(command_line) || repeat?(command_line) Readline::HISTORY.pop end command_line.chomp! command_line.strip! end yield command_line rescue Interrupt @display.break yield 'quit' end end end |