<commit_before>require 'keg'
require 'formula'

module Homebrew extend self
  def uninstall
    raise KegUnspecifiedError if ARGV.named.empty?

    if not ARGV.force?
      ARGV.kegs.each do |keg|
        keg.lock do
          puts "Uninstalling #{keg}..."
          keg.unlink
          keg.uninstall
          rm_opt_link keg.fname
          rm_pin keg.fname
        end
      end
    else
      ARGV.named.each do |name|
        name = Formula.canonical_name(name)

        # FIXME canonical_name is insane
        raise "Invalid usage" if name.include? '/'

        rack = HOMEBREW_CELLAR/name
        if rack.directory?
          puts "Uninstalling #{name}..."
          rack.children.each do |keg|
            if keg.directory?
              keg = Keg.new(keg)
              keg.unlink
              Formula.factory(keg.fname).unpin
              keg.rmtree
            end
          end
          rack.rmtree
        end

        rm_opt_link name
      end<commit_msg>uninstall: stop assuming kegs always map to formulae<commit_after>require 'keg'
require 'formula'

module Homebrew extend self
  def uninstall
    raise KegUnspecifiedError if ARGV.named.empty?

    if not ARGV.force?
      ARGV.kegs.each do |keg|
        keg.lock do
          puts "Uninstalling #{keg}..."
          keg.unlink
          keg.uninstall
          rm_opt_link keg.fname
          rm_pin keg.fname
        end
      end
    else
      ARGV.named.each do |name|
        name = Formula.canonical_name(name)

        # FIXME canonical_name is insane
        raise "Invalid usage" if name.include? '/'

        rack = HOMEBREW_CELLAR/name

        if rack.directory?
          puts "Uninstalling #{name}..."
          rack.subdirs.map { |d| Keg.new(d) }.each do |keg|
            keg.unlink
            keg.rmtree
          end
          rack.rmtree
        end

        rm_opt_link name
        rm_pin name
      end
{'fraction_non_alphanumeric': 0.07781282860147214, 'fraction_numerical': 0.0, 'mean_word_length': 1.5543624161073826, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4101729', 'n_tokens_mistral': 619, 'n_tokens_neox': 599, 'n_words': 149}