Class: Cl::Help::Cmds

Inherits:
Object
  • Object
show all
Defined in:
lib/cl/help/cmds.rb

Constant Summary collapse

HEAD =
%(Type "#{$0.split('/').last} help COMMAND [SUBCOMMAND]" for more details:\n)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmds) ⇒ Cmds

Returns a new instance of Cmds.


11
12
13
# File 'lib/cl/help/cmds.rb', line 11

def initialize(cmds)
  @cmds = cmds
end

Instance Attribute Details

#cmdsObject (readonly)

Returns the value of attribute cmds


9
10
11
# File 'lib/cl/help/cmds.rb', line 9

def cmds
  @cmds
end

Instance Method Details

#formatObject


15
16
17
# File 'lib/cl/help/cmds.rb', line 15

def format
  [HEAD, Table.new(list).format].join("\n")
end

#format_cmd(cmd) ⇒ Object


23
24
25
# File 'lib/cl/help/cmds.rb', line 23

def format_cmd(cmd)
  ["#{Usage.new(cmd).format}", cmd.summary]
end

#listObject


19
20
21
# File 'lib/cl/help/cmds.rb', line 19

def list
  cmds.any? ? cmds.map { |cmd| format_cmd(cmd) } : [['[no commands]']]
end