Class: Thunder::DefaultHelp

Inherits:
Object
  • Object
show all
Defined in:
lib/thunder/help/default.rb

Overview

Provides an easy to parse help formatter

Class Method Summary collapse

Class Method Details

.help_command(command_spec) ⇒ Object

See Also:

  • Thunder#help_command(command_spec)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/thunder/help/default.rb', line 6

def help_command(command_spec)
  preamble = determine_preamble
  footer = ""
  footer << command_spec[:description] + "\n" if command_spec[:description]
  footer << command_spec[:long_description] + "\n" if command_spec[:long_description]
  footer << "\n" + format_options(command_spec[:options]) if command_spec[:options]
  output = <<-EOS
Usage:
  #{preamble} #{command_spec[:usage]}

#{footer.strip}
  EOS
  output.rstrip
end

.help_list(commands) ⇒ Object

See Also:

  • Thunder#help_list(commands)


22
23
24
25
26
27
28
29
# File 'lib/thunder/help/default.rb', line 22

def help_list(commands)
  preamble = determine_preamble
  help = []
  commands.each do |name, command_spec|
    help << short_help(preamble, command_spec)
  end
  render_table(help)
end