Class: Jets::Command::Help

Inherits:
Object
  • Object
show all
Defined in:
lib/jets/command/help.rb

Class Method Summary collapse

Class Method Details

.text(namespaced_command) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/jets/command/help.rb', line 4

def text(namespaced_command)
  file = namespaced_command.to_s.gsub(':','/')
  path = File.expand_path("../help/#{file}.md", __FILE__)
  return IO.read(path) if File.exist?(path)

  # Also look up for a help folder within the current command folder
  called_from = caller.first.split(':').first
  unnamespaced_command = namespaced_command.to_s.split(':').last
  path = File.expand_path("../help/#{unnamespaced_command}.md", called_from)
  return IO.read(path) if File.exist?(path)
end