Class: Cl::Help::Cmds
- Inherits:
-
Struct
- Object
- Struct
- Cl::Help::Cmds
- Defined in:
- lib/cl/help/cmds.rb
Constant Summary collapse
- HEAD =
%(Type "%s help COMMAND [SUBCOMMAND]" for more details:\n)
Instance Attribute Summary collapse
-
#cmds ⇒ Object
Returns the value of attribute cmds.
-
#ctx ⇒ Object
Returns the value of attribute ctx.
Instance Method Summary collapse
Instance Attribute Details
#cmds ⇒ Object
Returns the value of attribute cmds
6 7 8 |
# File 'lib/cl/help/cmds.rb', line 6 def cmds @cmds end |
#ctx ⇒ Object
Returns the value of attribute ctx
6 7 8 |
# File 'lib/cl/help/cmds.rb', line 6 def ctx @ctx end |
Instance Method Details
#format ⇒ Object
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 |
#head ⇒ Object
13 14 15 |
# File 'lib/cl/help/cmds.rb', line 13 def head HEAD % ctx.name end |
#list ⇒ Object
17 18 19 |
# File 'lib/cl/help/cmds.rb', line 17 def list cmds.any? ? cmds.map { |cmd| format_cmd(cmd) } : [['[no commands]']] end |