Class: Gm::Notepad::InputHandlers::HelpHandler

Inherits:
DefaultHandler show all
Defined in:
lib/gm/notepad/input_handlers/help_handler.rb

Constant Summary collapse

HELP_PREFIX =
'?'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DefaultHandler

build_if_handled, #initialize, #lines

Constructor Details

This class inherits a constructor from Gm::Notepad::InputHandlers::DefaultHandler

Class Method Details

.handles?(input:) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/gm/notepad/input_handlers/help_handler.rb', line 8

def self.handles?(input:)
  return false unless input.match(/^\?/)
  true
end

Instance Method Details

#after_initialize!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gm/notepad/input_handlers/help_handler.rb', line 13

def after_initialize!
  [
    "Prefixes:",
    "\t? - Help (this command)",
    "\t+ - Query table names and contents",
    "\t<table_name: - Write the results to the given table",
    "",
    "Tokens:",
    "\t! - Skip expansion",
    "\t/search/ - Grep for the given 'search' within the prefix",
    "\t[index] - Target a specific 'index'",
    "\t{table_name} - expand_line the given 'table_name'"
  ].each do |text|
    input.for_rendering(text: text, to_interactive: true, to_output: false, expand_line: false)
  end
end