Class: Homesteading::Help

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

Constant Summary collapse

DEFAULT_HELP_DOC =
"README"

Constants inherited from Command

Command::COMMANDS

Instance Method Summary collapse

Methods inherited from Command

create, register

Instance Method Details

#defaultObject



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

def default
  help_doc_path = if ARGV.empty?
                    DEFAULT_HELP_DOC
                  elsif ARGV.first.match(/:/)
                    ARGV.first.sub(":", "-")
                  else
                    ARGV.first
                  end

  print(help_doc_path)
end


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

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