Module: Amp::Help::HelpUI

Extended by:
HelpUI
Included in:
HelpUI
Defined in:
lib/amp-front/help/help.rb

Overview

The really public-facing part of the Help system - the Help’s UI. This lets the outside world get at entries based on their names.

Instance Method Summary collapse

Instance Method Details

#print_entry(name, options = {}) ⇒ Object

Asks the UI system to print the entry with the given name, with the process’s current options.

This method is “smart” - it has to check to see what entries are available. If there’s more than one with the provided name, it helps the user pick the appropriate entry.



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/amp-front/help/help.rb', line 280

def print_entry(name, options = {})
  result = HelpRegistry[name.to_s]
  case result.size
  when 0
    raise abort("Could not find help entry \"#{name}\"")
  when 1
    puts result.first.text(options)
  when 2
    UI.choose do |menu|
      result.each do |entry|
        menu.choice("#{name} - #{entry.desc}") { puts entry.text(options) }
      end
    end
  end
end