Sha256: e79cf45a6f025f1fb2e386b65511eabf4c51ab4c9edfff809dc5c90b8d8173ba

Contents?: true

Size: 525 Bytes

Versions: 17

Compression:

Stored size: 525 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}", cmd.summary]
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cl-1.1.5 lib/cl/help/cmds.rb
cl-1.1.4 lib/cl/help/cmds.rb
cl-1.1.3 lib/cl/help/cmds.rb
cl-1.1.2 lib/cl/help/cmds.rb
cl-1.1.1 lib/cl/help/cmds.rb
cl-1.1.0 lib/cl/help/cmds.rb
cl-1.0.5 lib/cl/help/cmds.rb
cl-1.0.4 lib/cl/help/cmds.rb
cl-1.0.3 lib/cl/help/cmds.rb
cl-1.0.2 lib/cl/help/cmds.rb
cl-1.0.1 lib/cl/help/cmds.rb
cl-1.0.0 lib/cl/help/cmds.rb
cl-0.1.28 lib/cl/help/cmds.rb
cl-0.1.27 lib/cl/help/cmds.rb
cl-0.1.26 lib/cl/help/cmds.rb
cl-0.1.25 lib/cl/help/cmds.rb
cl-0.1.24 lib/cl/help/cmds.rb