class Gm::Notepad::InputHandlers::ShellOutHandler

Responsible for handling shell out commands

Constants

SHELL_OUT_HANDLER_REGEXP
TO_OUTPUT_REGEXP

Public Class Methods

handles?(input:) click to toggle source
# File lib/gm/notepad/input_handlers/shell_out_handler.rb, line 12
def self.handles?(input:)
  return false unless input.match(SHELL_OUT_HANDLER_REGEXP)
  true
end

Public Instance Methods

after_initialize!() click to toggle source
# File lib/gm/notepad/input_handlers/shell_out_handler.rb, line 17
def after_initialize!
  input.sub!(SHELL_OUT_HANDLER_REGEXP,'')
  if input.match(TO_OUTPUT_REGEXP)
    input.sub!(TO_OUTPUT_REGEXP, '')
    to_output = true
  else
    to_output = false
  end
  response = shell_handler.call(input)

  input.for_rendering(
    text: response,
    to_interactive: true,
    to_output: to_output,
    expand_line: false
  )
end