class Thor::Runner

def display_klasses(with_modules = false, klasses = Thor.subclasses)

def display_klasses(with_modules = false, klasses = Thor.subclasses)
  klasses -= [Thor, Thor::Runner] unless with_modules
  raise Error, "No Thor tasks available" if klasses.empty?
  
  if with_modules && !(yaml = thor_yaml).empty?
    max_name = yaml.max {|(xk,xv),(yk,yv)| xk.to_s.size <=> yk.to_s.size }.first.size
    modules_label = "Modules"
    namespaces_label = "Namespaces"
    column_width = [max_name + 4, modules_label.size + 1].max
    
    print "%-#{column_width}s" % modules_label
    puts namespaces_label
    print "%-#{column_width}s" % ("-" * modules_label.size)
    puts "-" * namespaces_label.size
    
    yaml.each do |name, info|
      print "%-#{column_width}s" % name
      puts info[:constants].map {|c| Thor::Util.constant_to_thor_path(c)}.join(", ")
    end
  
    puts
  end
  
  # Calculate the largest base class name
  max_base = klasses.max do |x,y| 
    Thor::Util.constant_to_thor_path(x.name).size <=> Thor::Util.constant_to_thor_path(y.name).size
  end.name.size
  
  # Calculate the size of the largest option description
  max_left_item = klasses.max do |x,y| 
    (x.maxima.usage + x.maxima.opt).to_i <=> (y.maxima.usage + y.maxima.opt).to_i
  end
  
  max_left = max_left_item.maxima.usage + max_left_item.maxima.opt
  
  unless klasses.empty?
    puts # add some spacing
    klasses.each { |k| display_tasks(k, max_base, max_left); }
  else
    puts "\033[1;34mNo Thor tasks available\033[0m"
  end
end