Class: Clin::LineReader::Readline

Inherits:
Basic
  • Object
show all
Defined in:
lib/clin/line_reader/readline.rb

Overview

Readline line scanner. Allow autocomplete and history. Use Readline.readline Valid options: echo: [Boolean] Set to false not to show on screen what you type(e.g. password) autocomplete: List of values to autocomplete or proc that return the values add_to_history: [Boolean] Add the reply to the history, default: true

Instance Attribute Summary

Attributes inherited from Basic

#options, #statement

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Basic

#initialize

Constructor Details

This class inherits a constructor from Clin::LineReader::Basic

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/clin/line_reader/readline.rb', line 11

def self.available?
  Clin.use_readline?
end

Instance Method Details

#readlineObject



15
16
17
18
19
20
21
22
23
# File 'lib/clin/line_reader/readline.rb', line 15

def readline
  if echo?
    Readline.completion_append_character = nil
    set_completion_proc
    Readline.readline(statement, add_to_history?)
  else # Use basic method to fetch
    super
  end
end