# File lib/cri/command.rb, line 295
    def help
      text = ''

      # Append usage
      if usage
        path = [ self.supercommand ]
        path.unshift(path[0].supercommand) until path[0].nil?
        full_usage = path[1..-1].map { |c| c.name + ' ' }.join + usage
        text << "usage: #{full_usage}\n"
      end

      # Append aliases
      unless aliases.empty?
        text << "\n"
        text << "aliases: #{aliases.join(' ')}\n"
      end

      # Append short description
      if summary
        text << "\n"
        text << summary + "\n"
      end

      # Append long description
      if description
        text << "\n"
        text << description.wrap_and_indent(78, 4) + "\n"
      end

      # Append subcommands
      unless self.commands.empty?
        text << "\n"
        text << (self.supercommand ? 'subcommands' : 'commands') << ":\n"
        text << "\n"
        length = self.commands.inject(0) { |m,c| [ m, c.name.size ].max }
        self.commands.sort_by { |cmd| cmd.name }.each do |cmd|
          text << sprintf("    %-#{length+4}s %s\n",
            cmd.name,
            cmd.summary)
        end
      end

      # Append options
      groups = { 'options' => self.option_definitions }
      if self.supercommand
        groups["options for #{self.supercommand.name}"] = self.supercommand.global_option_definitions
      end
      length = groups.values.inject(&:+).inject(0) { |m,o| [ m, o[:long].size ].max }
      groups.each_pair do |name, defs|
        unless defs.empty?
          text << "\n"
          text << "#{name}:\n"
          text << "\n"
          defs.sort { |x,y| x[:long] <=> y[:long] }.each do |opt_def|
            text << sprintf(
              "    -%1s --%-#{length+4}s %s\n",
              opt_def[:short],
              opt_def[:long],
              opt_def[:desc])
          end
        end
      end

      # Return text
      text
    end