Module: Jets::CLI::Help

Extended by:
Help
Included in:
Help
Defined in:
lib/jets/cli/help.rb

Instance Method Summary collapse

Instance Method Details

#text(namespaced_command) ⇒ Object



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

def text(namespaced_command)
  file = namespaced_command.to_s.tr(":", "/")
  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(1..1).first.split(":").first
  unnamespaced_command = namespaced_command.to_s.split(":").last
  path = File.expand_path("../help/#{unnamespaced_command}.md", called_from)
  IO.read(path) if File.exist?(path)
end