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



37
38
39
# File 'lib/hammer_cli/full_help.rb', line 37

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


41
42
43
44
45
46
47
48
49
# File 'lib/hammer_cli/full_help.rb', line 41

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


61
62
63
# File 'lib/hammer_cli/full_help.rb', line 61

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


51
52
53
54
55
56
57
58
59
# File 'lib/hammer_cli/full_help.rb', line 51

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