Class: Cl::Help::Cmds

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

Constant Summary collapse

HEAD =
%(Type "%s help COMMAND [SUBCOMMAND]" for more details:\n)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cmdsObject

Returns the value of attribute cmds

Returns:

  • (Object)

    the current value of cmds



6
7
8
# File 'lib/cl/help/cmds.rb', line 6

def cmds
  @cmds
end

#ctxObject

Returns the value of attribute ctx

Returns:

  • (Object)

    the current value of ctx



6
7
8
# File 'lib/cl/help/cmds.rb', line 6

def ctx
  @ctx
end

Instance Method Details

#formatObject



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

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

#format_cmd(cmd) ⇒ Object



21
22
23
# File 'lib/cl/help/cmds.rb', line 21

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

#headObject



13
14
15
# File 'lib/cl/help/cmds.rb', line 13

def head
  HEAD % ctx.name
end

#listObject



17
18
19
# File 'lib/cl/help/cmds.rb', line 17

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