Class: HammerCLI::FullHelpCommand::MDAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/hammer_cli/full_help.rb

Instance Method Summary collapse

Instance Method Details

#command_name(parent, command_name) ⇒ Object



30
31
32
# File 'lib/hammer_cli/full_help.rb', line 30

def command_name(parent, command_name)
  "#{parent} #{command_name}"
end


34
35
36
37
38
39
40
41
42
# File 'lib/hammer_cli/full_help.rb', line 34

def print_command(name, description, help)
  print_heading(name, name.split.length)
  puts description
  puts
  puts "```"
  puts help
  puts "```"
  puts
end


54
55
56
# File 'lib/hammer_cli/full_help.rb', line 54

def print_heading(text, level=1)
  puts '#'*level + ' ' + text
end


44
45
46
47
48
49
50
51
52
# File 'lib/hammer_cli/full_help.rb', line 44

def print_toc(cmd)
  names = cmd.recognised_subcommands.collect do |sub_cmd|
    sub_cmd.names[0]
  end
  names.sort.each do |name|
    puts "- [%s](#hammer-%s)" % [name, name.gsub(' ', '-')]
  end
  puts
end