Module: Ledmon::Monster::Terminal

Extended by:
ActiveSupport::Concern, Forwardable
Included in:
Executor
Defined in:
lib/ledmon/monster/terminal.rb

Instance Method Summary collapse

Instance Method Details

#promptObject



6
7
8
# File 'lib/ledmon/monster/terminal.rb', line 6

def prompt
  @prompt ||= TTY::Prompt.new
end

#safe_promptObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ledmon/monster/terminal.rb', line 10

def safe_prompt
  if client?
    prompt
  else
    @safe_prompt ||= Class.new do
      attr_reader :logger

      def initialize(logger)
        @logger = logger
      end

      def keypress
        sleep 1
      end

      def method_missing(method_name, *args, &block)
        logger.warn "Attempted to call terminal prompt method '#{method_name}' in a non-client context. This is not supported."
      end
    end.new(logger)
  end
end