Sha256: 310e01c810baaac80e2765083765bdd62796eee5e459a0a379f6deafc96c306b

Contents?: true

Size: 464 Bytes

Versions: 1

Compression:

Stored size: 464 Bytes

Contents

require 'cl/format/table'
require 'cl/format/usage'

module Cl
  class Format
    class List < Struct.new(:cmds)
      HEAD = %(Type "#{$0.split('/').last} help COMMAND [SUBCOMMAND]" for more details:\n)

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

      def list
        cmds.map { |cmd| format_cmd(cmd) }
      end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cl-0.0.4 lib/cl/format/list.rb