Sha256: b1aad0afee0ea0893c1f0ea17149704e4491d479aeb4a2e652bf4aa57b25476e

Contents?: true

Size: 531 Bytes

Versions: 6

Compression:

Stored size: 531 Bytes

Contents

require 'cl/help/table'
require 'cl/help/usage'

class Cl
  class Help
    class Cmds < Struct.new(:ctx, :cmds)
      HEAD = %(Type "%s help COMMAND [SUBCOMMAND]" for more details:\n)

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

      def head
        HEAD % ctx.name
      end

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

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

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
travis-cl-1.2.4 lib/cl/help/cmds.rb
cl-1.2.4 lib/cl/help/cmds.rb
cl-1.2.3 lib/cl/help/cmds.rb
cl-1.2.2 lib/cl/help/cmds.rb
cl-1.2.1 lib/cl/help/cmds.rb
cl-1.2.0 lib/cl/help/cmds.rb