Class: Homesteading::Help

Inherits:
Object
  • Object
show all
Defined in:
lib/homesteading/commands/help.rb

Constant Summary collapse

DEFAULT_HELP_DOC =
"README"

Class Method Summary collapse

Class Method Details

.default(options = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/homesteading/commands/help.rb', line 6

def default(options=nil)
  if options.nil?
    help_doc_path = DEFAULT_HELP_DOC
  elsif options.first.match(/:/)
    first, last   = options.first.split(":")
    help_doc_path = first + "-" + last
  else
    help_doc_path = options.first
  end

  print(help_doc_path)
end


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/homesteading/commands/help.rb', line 19

def print(path)
  # TODO better way?
  help_dir = File.expand_path("../../../../help/", __FILE__)
  file     = "#{help_dir}/#{path}.md"

  puts
  unless File.exist?(file)
    file = "#{help_dir}/#{DEFAULT_HELP_DOC}.md"
    puts "Unknown command. No help docs about that."
    puts
  end

  puts File.read(file)
  puts
end